here's a simple lto test on object with virtual methods: $ LANG=C make clean all CPPFLAGS=-DCRASH rm -f *.o *.s *.ii m g++-4.5 -Wall -g2 -O3 -DCRASH a.cpp -c -flto g++-4.5 -Wall -g2 -O3 -DCRASH m.cpp -c -flto g++-4.5 -Wall -g2 -O3 -DCRASH a.o m.o -o m -fwhopr --save-temps -fverbose-asm __base_dtor /6(-1) @0x7f82e673dea0 (clone of __base_dtor /3) availability:not_available (25 after inlining) (7 after inlining) needed address_taken body externally_visible finalized called by: main/1 calls: lto1: internal compiler error: failed to reclaim unneeded function Please submit a full bug report, with preprocessed source if appropriate. another variant of testcase with dynamic object allocation compiles but virtual calls aren't optimized. $ LANG=C make clean all rm -f *.o *.s *.ii m g++-4.5 -Wall -g2 -O3 a.cpp -c -flto g++-4.5 -Wall -g2 -O3 m.cpp -c -flto g++-4.5 -Wall -g2 -O3 a.o m.o -o m -fwhopr --save-temps -fverbose-asm m_a.wpa.s fragments: indirect foo() call not optimized. movq $_ZTV1X+16, (%rax) call *_ZTV1X+32(%rip) bar() call optimized :) movq %rbp, %rsi movl $.LC1, %edi xorl %eax, %eax call printf indirect destructor call not optimized. movq (%rbx), %rax movq %rbx, %rdi call *8(%rax)
Created attachment 20093 [details] testcase.
i should mention that at -O2 with object allocated on *stack* lto does a nice job and optimize indirect calls in main(): call _ZN1X3fooEv (...) call _ZN1X3barEv (...) call _ZN1XD1Ev with dynamic allocation there's no progress.
I'm not sure you are supposed to mix -flto and -fwhopr (though it probably just works). This is btw the most prominent ICE I see when building SPEC with -fwhopr and checking enabled.
This happens building ffmpeg --enable-shared with -fwhopr. I can make a testcase out of that if needed.
(In reply to comment #3) > I'm not sure you are supposed to mix -flto and -fwhopr (though it probably > just works). This is btw the most prominent ICE I see when building SPEC > with -fwhopr and checking enabled. mixing -flto/-fwhopr is unnecessary. pure -fwhopr is enough to reproduce an ICE.
The problem no longer occurs.
-fwhopr and -flto are intended to be interchangeable at link time. So it does not matter with what flag you build the .o objects. The problem was fixed by the clone streaming fix I submitted last week. Honza