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) -- Summary: lto1: internal compiler error: failed to reclaim unneeded function Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pluto at agmk dot net GCC build triplet: x86_64-gnu-linux GCC host triplet: x86_64-gnu-linux GCC target triplet: x86_64-gnu-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43342