This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/65534] tailcall not optimized away


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65534

--- Comment #1 from Jan Hubicka <hubicka at ucw dot cz> ---
> #ifndef OPTIMIZE_MANUALLY
> void setutent(void) {
>     ((void)0);
>     __setutent_unlocked();
>     ((void)0);
> }
> #else
> extern __typeof (__setutent_unlocked) setutent
>     __attribute__ ((alias ("__setutent_unlocked")));
> #endif

I do not think GCC can safely optimize this, becuase in the first
case &setutent != &__setutent_unlocked, wile in the optimized
case the addresses are equal.

This is something we looked into with Martin Liska but was late for
GCC 5.  We have -fmerge-all-constants, we may want to introduce something
like -fmerge-all-functions declaring that this special case does not matter
(curiously enough there is real world code that actually compares the addresses
of otherwise equivalent functions, like in GCC PCH implementation).

Second thing is to make ipa-ICF to discover wrappers and consider them
semantically equivalent to their target.  Something I also discussed with
Martin.

So hopefully early next stage1 this can be implemented.

Honza


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]