> On 4/22/20 8:11 PM, Jan Hubicka wrote: > > > On Mon, 2020-04-20 at 11:34 +0200, Martin Liška wrote: > > > > Hi. > > > > > > > > The patch prevents a ifunc alias from removal in remove unreachable > > > > nodes. > > > > Note that ifunc alias lives in a COMDAT section and so that > > > > cgraph_node::can_remove_if_no_direct_calls_and_refs_p returned true for > > > > it. > > > > > > > > Patch can bootstrap on x86_64-linux-gnu and survives regression tests. > > > > I was unable to create a lto test-case where a linked binary could be > > > > scanned for assembly. > > > > > > > > Ready to be installed? > > > > Thanks, > > > > Martin > > > > > > > > gcc/ChangeLog: > > > > > > > > 2020-04-20 Martin Liska <mli...@suse.cz> > > > > > > > > PR lto/94659 > > > > * cgraph.h > > > > (cgraph_node::can_remove_if_no_direct_calls_and_refs_p): > > > > Do not remove ifunc_resolvers in remove unreachable nodes in > > > > LTO. > > > OK > > Is it intended to keep the comdat group alive even when the function is > > not used by the current translation unit? > > Yes, if you take a look at the mentioned PR, the function is exported and used > by a different TU. > > Or do you have a particular test-case which you're talking about?
Well, first I think you want to use force_output flag when you create the alias instead of modifying can_remove_if_no_direct_calls_and_refs_p. I wonder what happens when your function is static and we optimize away all uses of it - then I think GCC should optimize it away. Similarly if the function is comdat: __attribute__((target_clones("default,avx"))) inline int f1() { return 2; } int main() { return f1(); } We should avoid outputting it to every compilation unit that includes the header. I do not recall, why that function is comdat at first place? Honza