Bug 41756 - LTO: -flto -O1 linking files compiled with -fno-exceptions with ones compiled with exceptions yields error "BB 14 can not throw but has an EH edge"
Summary: LTO: -flto -O1 linking files compiled with -fno-exceptions with ones compiled...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: 10.0
Assignee: Not yet assigned to anyone
URL:
Keywords: lto
Depends on:
Blocks:
 
Reported: 2009-10-19 16:54 UTC by Török Edwin
Modified: 2021-08-26 00:22 UTC (History)
2 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: 2009-10-19 17:34:08


Attachments
SourceMgr.i (71.51 KB, text/plain)
2009-10-19 16:55 UTC, Török Edwin
Details
AsmMatcherEmitter.i.bz2 (127.57 KB, application/octet-stream)
2009-10-19 16:56 UTC, Török Edwin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Török Edwin 2009-10-19 16:54:29 UTC
$ /home/edwin/inst/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/home/edwin/inst/bin/g++
COLLECT_LTO_WRAPPER=/home/edwin/inst/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.5.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure --enable-lto --enable-languages=c,c++ --enable-gold
Thread model: posix
gcc version 4.5.0 20091019 (experimental) (GCC)

sh -x script
+ /home/edwin/inst/bin/g++ -fPIC SourceMgr.i -flto -fno-exceptions -O1 -c -o SourceMgr.o
+ /home/edwin/inst/bin/g++ -fPIC AsmMatcherEmitter.i -flto -O1 -c -o AsmMatcher.o
+ /home/edwin/inst/bin/g++ -flto -use-linked-plugin -O1 AsmMatcher.o SourceMgr.o -shared
In function ‘EmitIsSubclass’:
lto1: error: BB 14 can not throw but has an EH edge
lto1: error: BB 15 can not throw but has an EH edge
lto1: error: BB 16 can not throw but has an EH edge
lto1: error: BB 18 can not throw but has an EH edge
lto1: error: BB 19 can not throw but has an EH edge
lto1: error: BB 20 can not throw but has an EH edge
lto1: error: BB 22 can not throw but has an EH edge
lto1: error: BB 23 can not throw but has an EH edge
lto1: error: BB 25 can not throw but has an EH edge
lto1: error: BB 26 can not throw but has an EH edge
lto1: error: BB 27 can not throw but has an EH edge
lto1: error: BB 30 can not throw but has an EH edge
lto1: internal compiler error: verify_flow_info failed
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: /home/edwin/inst/bin/g++ returned 1 exit status
collect2: lto-wrapper returned 1 exit status
Comment 1 Török Edwin 2009-10-19 16:55:18 UTC
Created attachment 18827 [details]
SourceMgr.i

preprocessed SourceMgr.i
Comment 2 Török Edwin 2009-10-19 16:56:17 UTC
Created attachment 18828 [details]
AsmMatcherEmitter.i.bz2

bzipped preprocessed AsmMatcherEmitter.i
Comment 3 Török Edwin 2009-10-19 16:58:13 UTC
ld -v
GNU gold (GNU Binutils for Debian 2.20) 1.9

This happens only if I use all of -flto -O1 -use-linker-plugin, not using -O1, or not using -use-linker-plugin hides the bug (and not using -flto too of course).
Comment 4 Török Edwin 2009-10-19 16:59:57 UTC
(In reply to comment #3)
> ld -v
> GNU gold (GNU Binutils for Debian 2.20) 1.9
> 
> This happens only if I use all of -flto -O1 -use-linker-plugin, not using -O1,
> or not using -use-linker-plugin hides the bug (and not using -flto too of
> course).
> 

Actually -use-linker-plugin makes no difference


Comment 5 Steven Bosscher 2009-10-19 17:34:08 UTC
You can't merge no-exception and exception code, it seems.  Should exceptions be enabled per-function for LTO?
Comment 6 Richard Biener 2009-10-20 09:35:08 UTC
Even that would be difficult - how would you inline between such functions?
I think the only way is to force -fexceptions during the link stage if one
translation unit did have it enabled.  The -fno-exception TUs should have
all stmts marked as not throwing.

Sort of, but well - this is a very low priority bug.  (Falls into the
class of "different flags used for compiling and linking")

I'll try a very simple hack.
Comment 7 Jan Hubicka 2009-12-11 11:39:01 UTC
I would vote for LTO frotnend simply sorrying when seeing units with and without exceptions.

Honza
Comment 8 Richard Biener 2009-12-11 12:16:30 UTC
I wonder if we should simply ignore -fno-exceptions/-fexceptions passed to
lto1 and rely on the automated discovery.

The testcase btw works for me on i?86.

The proposed patch would delete handling of OPT_fexceptions from
register_user_option_p and add flag_exceptions = 0 to lto_init_options
in case you can still reproduce the issue.
Comment 9 Drea Pinski 2021-08-26 00:22:12 UTC
Fixed for GCC 8 with r8-4560.
Though fixed fully with r10-3246.