Bug 37352 - thunks for virtual function should work on lto
Summary: thunks for virtual function should work on lto
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: 4.5.0
Assignee: Diego Novillo
URL:
Keywords: lto
: 41602 41663 42009 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-09-03 16:27 UTC by Rafael Avila de Espindola
Modified: 2009-11-30 12:36 UTC (History)
6 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2008-12-31 19:32:54


Attachments
testcase (105 bytes, text/x-csrc)
2008-11-19 17:47 UTC, Rafael Avila de Espindola
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Avila de Espindola 2008-09-03 16:27:58 UTC
From http://gcc.gnu.org/ml/gcc-patches/2008-03/msg00349.html:

   Currently the thunks for a function are 
   emitted from the frontend, exactly when the function itself is emitted
   (as RTL).  The frontend does some analysis of thunks beforehand 
   already, but I simply deactivated emission of thunks for my experiment.
   This needs to be done before IPA, either by making thunks a middle-end
   concept, or implementing alternate entry points for real

Maybe it is possible to generate thunks eagerly as a first solution?
Comment 1 Rafael Avila de Espindola 2008-11-19 17:47:49 UTC
Created attachment 16722 [details]
testcase
Comment 2 Rafael Avila de Espindola 2008-11-19 17:49:27 UTC
To reproduce:
g++ -O2 -c thunk.C -flto-single -o thunk-lto.o
g++ -O2 -c thunk.C -o thunk.o

readelf -s thunk.o  | grep Th
    35: 0000000000000000     6 FUNC    WEAK   DEFAULT   19 _ZThn8_N1C1fEv
readelf -s thunk-lto.o  | grep Th
    26: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZThn8_N1C1fEv
Comment 3 Rafael Avila de Espindola 2008-11-19 17:53:33 UTC
This case can be easily fixed by setting targetm.asm_out.can_output_mi_thunk to NULL. This will introduce a performance regression.

The only case that will be missing is varg functions.

The llvm equivalent bug is http://llvm.org/bugs/show_bug.cgi?id=2861.
Comment 4 Andrew Pinski 2008-12-31 19:26:06 UTC
Confirmed.
Comment 5 Diego Novillo 2008-12-31 19:32:48 UTC
Initial fix at http://gcc.gnu.org/ml/gcc-patches/2008-12/msg00953.html
Keeping open as thunks with varargs are still broken.
Comment 6 Richard Biener 2009-10-06 13:53:08 UTC
*** Bug 41602 has been marked as a duplicate of this bug. ***
Comment 7 Richard Biener 2009-10-06 13:54:10 UTC
Another testcase in PR41602.  SPEC CPU 2006 450.soplex is the only one in
SPEC 2000/2006 to run into this issue.
Comment 8 Richard Biener 2009-10-10 18:44:43 UTC
*** Bug 41663 has been marked as a duplicate of this bug. ***
Comment 9 Andrew Pinski 2009-11-11 18:28:38 UTC
*** Bug 42009 has been marked as a duplicate of this bug. ***
Comment 10 Richard Biener 2009-11-11 20:32:30 UTC
There's a simple workaround for most cases, condition asm-thunks on !flag_write_lto.  We'll do this if a proper implementation doesn't come up
for 4.5.
Comment 11 Richard Biener 2009-11-30 12:36:57 UTC
Fixed by Honza.