https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106725
--- Comment #3 from rguenther at suse dot de <rguenther at suse dot de> --- On Wed, 24 Aug 2022, dthorn at google dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106725 > > --- Comment #2 from Daniel Thornburgh <dthorn at google dot com> --- > (In reply to Richard Biener from comment #1) > > If GCC, with LTO, would partition the program into two LTRANS partitions, > > one containing main and bar and one containing foo then applying this > > optimization promise during LTRANS time on the main/bar partition would > > be wrong as you say - but I think GCC doesn't do this. > > In this case, foo() was already compiled to native code outside of LTO. > Wouldn't this then mean that its contents wouldn't be available for the WPA > and > LTRANS phases of the LTO code generation? It seems like the compiler wouldn't > know that foo() might call bar(), and the presence of `__attribute__((leaf))` > would cause it to assume that it doesn't call bar(). As said, GCC shouldn't assume this since leaf is defined at translation unit level, not at LTO level.