Patch to fix mark_constant_function
Jeffrey A Law
Tue Oct 17 20:54:00 GMT 2000
In message <200009212147.RAA03216@jwlab.FEITH.COM>you write:
> This patch fixes mark_constant_function which has been busted since
> a change on 2000-02-18. It also addresses a long standing issue
> where recursive functions and functions with loops were considered
> as constant function candidates ... several people pointed out that
> this is undesirable since the function might never return which counts
> as a side effect. This patch passes make bootstrap and make check on
> IBM AIX 4.3, Solaris 7 SPARC, and Compaq Tru64 UNIX 4.0f.
> Thu Sep 21 02:41:10 EDT 2000 John Wehle (email@example.com)
> * alias.c: Include basic-block.h.
> (loop_p): New function.
> (mark_constant_function): Use it. Don't check pure functions.
> Initialize and end alias analysis.
> (nonlocal_mentioned_p): Rename from nonlocal_reference_p.
> Don't make a special exception for recursion. Handle
> UNSPEC_VOLATILE. Don't assume ASM_OPERANDS is non-local
> unless it's volatile.
> * Makefile.in (alias.o): Update dependencies.
The non-loop stuff looks good and you should install it.
I'm a little concerned about the efficiency of the loop detection code;
it appears to be a little heavyweight.
It seems to me that you can detect loops in the CFG quickly by doing a
DFS traversal, giving each node a DFS number.
If any block has a successor with a smaller DFS number than the block itself,
then you've got a loop. Right?
More information about the Gcc-patches