[PATCH] Fix for PR51879 - Missed tail merging with non-const/pure calls

Jakub Jelinek jakub@redhat.com
Wed Apr 25 10:10:00 GMT 2012


On Wed, Apr 25, 2012 at 11:57:09AM +0200, Richard Guenther wrote:
> void *foo ()
> {
>   return __builtin_return_address (0);
> }
> 
> void *bar (_Bool b)
> {
>   if (b)
>     return foo ();
>   else
>     return foo ();
> }
> 
> int main()
> {
>   if (bar(true) == bar(false))
>     abort ();
> }
> 
> ok ... outside of the scope of standard "C", but we certainly _can_ do this.
> Which would question tail-merging the above at all, of course.

I don't think we guarantee the above, after all, even pure functions may
use __builtin_return_address (0) - it doesn't modify memory, and we happily
remove pure calls, CSE the return values etc.

	Jakub



More information about the Gcc-patches mailing list