Bug 43342 - lto1: internal compiler error: failed to reclaim unneeded function
Summary: lto1: internal compiler error: failed to reclaim unneeded function
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
URL:
Keywords: lto
Depends on:
Blocks:
 
Reported: 2010-03-12 10:03 UTC by Pawel Sikora
Modified: 2010-04-26 12:41 UTC (History)
3 users (show)

See Also:
Host: x86_64-gnu-linux
Target: x86_64-gnu-linux
Build: x86_64-gnu-linux
Known to work:
Known to fail:
Last reconfirmed: 2010-03-12 11:23:46


Attachments
testcase. (795 bytes, application/octet-stream)
2010-03-12 10:05 UTC, Pawel Sikora
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pawel Sikora 2010-03-12 10:03:24 UTC
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)
Comment 1 Pawel Sikora 2010-03-12 10:05:06 UTC
Created attachment 20093 [details]
testcase.
Comment 2 Pawel Sikora 2010-03-12 10:11:45 UTC
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.
Comment 3 Richard Biener 2010-03-12 11:23:46 UTC
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.
Comment 4 astrange+gcc@gmail.com 2010-03-14 23:33:50 UTC
This happens building ffmpeg --enable-shared with -fwhopr. I can make a testcase out of that if needed.
Comment 5 Pawel Sikora 2010-03-15 11:28:02 UTC
(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.

Comment 6 Richard Biener 2010-04-26 11:32:24 UTC
The problem no longer occurs.
Comment 7 Jan Hubicka 2010-04-26 12:41:50 UTC
-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