[m-rev.] for review: --inform-ite-instead-of-switch
Julien Fischer
juliensf at csse.unimelb.edu.au
Fri Nov 23 18:06:15 AEDT 2007
On Fri, 23 Nov 2007, Zoltan Somogyi wrote:
> Add a new compiler option. --inform-ite-instead-of-switch. If this is enabled,
> the compiler will generate informational messages about if-then-elses that
> it thinks should be converted to switches for the sake of program reliability.
>
> Act on the output generated by this option.
>
> compiler/simplify.m:
> Implement the new option.
>
> Fix an old bug that could cause us to generate warnings about code
> that was OK in one duplicated copy but not in another (where a switch
> arm's code is duplicated due to the case being selected for more than
> one cons_id).
>
> compiler/options.m:
> Add the new option.
>
> Add a way to test for the bug fix in simplify.
>
> doc/user_guide.tex:
> Document the new option.
s/tex:/texi:/
>
> NEWS:
> Mention the new option.
>
> library/*.m:
> mdbcomp/*.m:
> browser/*.m:
> compiler/*.m:
> deep_profiler/*.m:
> Convert if-then-elses to switches at most of the sites suggested by the
> new option. At the remaining sites, switching to switches would have
> nontrivial downsides. This typically happens with the switched-on type
> has many functors, and we treat one or two specially (e.g. cons/2 in
> the cons_id type).
>
> Perform misc cleanups in the vicinity of the if-then-else to switch
> conversions.
>
> In a few cases, improve the error messages generated.
>
> compiler/accumulator.m:
> compiler/hlds_goal.m:
> (Rename and) move insts for particular kinds of goal from
> accumulator.m to hlds_goal.m, to allow them to be used in other
> modules. Using these insts allowed us to eliminate some if-then-elses
> entirely.
>
> compiler/exprn_aux.m:
> Instead of fixing some if-then-elses, delete the predicates containing
> them, since they aren't used, and (as pointed out by the new option)
> would need considerable other fixing if they were ever needed again.
>
> compiler/lp_rational.m:
> Add prefixes to the names of the function symbols on some types,
> since without those prefixes, it was hard to figure out what type
> the switch corresponding to an old if-then-else was switching on.
>
> tests/invalid/reserve_tag.err_exp:
> Expect a new, improved error message.
I've had a quick look through this and can't see anything wrong.
You can go ahead and commit it if you like - I will post any other
review comments I have sometime over the weekend.
Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list