I've come across this verify_flow_info failure when attempting to LTO build Firefox. I'm attaching a small testcase (I'm using trunk revision 208276 on x86-64-linux), to reproduce do: $ ~/gcc/trunk/inst/bin/gcc -c -O2 -flto gtod1.c $ ~/gcc/trunk/inst/bin/gcc -c -O2 -flto gtod2.c $ ~/gcc/trunk/inst/bin/gcc -O2 -flto gtod1.o gtod2.o gtod2.c: In function ‘main’: gtod2.c:41:5: error: control flow in the middle of basic block 6 int main (void) ^ gtod2.c:41:5: error: control flow in the middle of basic block 6 gtod2.c:41:5: error: control flow in the middle of basic block 6 gtod2.c:41:5: internal compiler error: verify_flow_info failed The order of .o files in the linking stage is important. My artificial testcase declares gettimeofday itself, twice, each time with different attributes on purpose. When building FF, all declarations claim to come from /usr/include/sys/time.h, I do not know why some of them lost or did not get their attributes. The problem with loosing the leaf attribute is that calls from function that calls setjmp are considered control flow statements unless they are without side effects or leaf (see stmt_ends_bb_p, is_ctrl_altering_stmt and call_can_make_abnormal_goto). Therefore, if a leaf attribute is lost, calls to that functions suddenly may need to break BBs or face the verifiers wrath.
Created attachment 32289 [details] Part one of a testcase
Created attachment 32290 [details] Part two of a testcase
Confirmed.
Created attachment 32291 [details] Untested proposed fix Untested proposed fix
Shouldn't fixup_cfg fix this up? Simply prefering the decl with attributes isn't enough if you attach an urelated attribute to both fns as well.
OTOH, why do we have to merge the decls/cgraph nodes at all? Can't we simply make them aliases if tree merging decides the decls are not equal?
(In reply to Richard Biener from comment #5) > Shouldn't fixup_cfg fix this up? Simply prefering the decl with attributes > isn't enough if you attach an urelated attribute to both fns as well. Yes, I know. I did not really mean to call it a "proposed" fix, did that somewhat automatically. On the other hand, I am able to slim-LTO build Firefox with the patch though. (In reply to Richard Biener from comment #6) > OTOH, why do we have to merge the decls/cgraph nodes at all? Can't we simply > make them aliases if tree merging decides the decls are not equal? Good idea, this might indeed be the best way to fix this. (Although I do not really know what needs to be done to turn a previously proper decl and its symtab node into an alias. Honza, do you think it would be difficult?).
*** Bug 60721 has been marked as a duplicate of this bug. ***
(In reply to Richard Biener from comment #8) > *** Bug 60721 has been marked as a duplicate of this bug. *** See there for another proposed fix to retain per-call 'leaf' (well, no-abnormal-goto) status.
(In reply to Richard Biener from comment #9) > (In reply to Richard Biener from comment #8) > > *** Bug 60721 has been marked as a duplicate of this bug. *** > > See there for another proposed fix to retain per-call 'leaf' (well, > no-abnormal-goto) status. Btw, similar to this flag a flag for a per-call 'noreturn' status should be added as well, getting rid of that MODIFIED_NORETURN_CALLS red herring on the way (basically defer committing 'noreturn' from a decl to all callers until a suitable time). I suppose different 'noreturn' status in LTO units can also cause a similar issue where a (no longer after merging) noreturn call ending BB fails to have a fallthru edge.
> OTOH, why do we have to merge the decls/cgraph nodes at all? Can't we simply > make them aliases if tree merging decides the decls are not equal? If we do so, we would never merge external declaration from one unit with definition from other, so everything would go through aliases effectively doubling the symtab. Also aliases currently ar different symbols, not different tree representation of the same symbol, so one would need to rename the declaration and make it to bubble all the way into the assembler file. We can resort to not merging in selected cases, but I would prefer to do that only when we have very good reason why we want to do so.
GCC 4.9.0 has been released
Same problem can be seen in Chromium. The final binary contains about ~3500 usages of a function with different DECL attributes. Problematic is just one function: sigaction/538949 (sigaction) @0x7f0fb8916450 DECL_ATTR: sigaction/718813 (sigaction) @0x7f0fb7db58a0 DECL_ATTR: __leaf__ , __nothrow__ Thus, preserving both variants of the function would not increase symtab significantly.
Created attachment 32997 [details] RFC patch After playing around with aliases (of extern symbols) for a while I decided that any such fix to this problem would be too invasive and generally terrible. Therefore, I set out to prepare a patch that would put the leaf flag into individual gimple call statements and that would also do what Richi suggested in comment #10, ie. remove MODIFIED_NORETURN_CALLS by having a noreturn flag in calls too. I may not get back to this for a while so I'm posting what I've got, inviting comments on the general direction of the patch, even though it is not at the submission level yet. It bootstraps but it introduces one (yet totally unexamined) asan test failure. I'm also worried about the occasional discrepancy between the decl and the call noreturn flags, it would be nice to make it somehow clearer when to use what. I've also started to think that setting both the two new flags lazily in the cfg cleanup was probably a mistake. Verifier requires special treatment when noreturn IS set and when leaf IS NOT set, which means that the cfg cleanup sometimes must be run even though the cfg has not actually changed (but a call was re-built) which is weird. So in the next iteration I'll probably try to set the leaf flag when building the statement and maintain it from that point on. But that may not happen until late July. Meanwhile, almost anyone bumping into this problem can use the first provisional fix.
GCC 4.9.1 has been released.
Author: wmi Date: Wed Aug 20 16:47:12 2014 New Revision: 214233 URL: https://gcc.gnu.org/viewcvs?rev=214233&root=gcc&view=rev Log: 2014-08-20 Martin Jambor <mjambor@suse.cz> Wei Mi <wmi@google.com> PR ipa/60449 PR middle-end/61776 * tree-ssa-operands.c (update_stmt_operands): Remove MODIFIED_NORETURN_CALLS. * tree-cfgcleanup.c (cleanup_call_ctrl_altering_flag): New func. (cleanup_control_flow_bb): Use cleanup_call_ctrl_altering_flag. (split_bb_on_noreturn_calls): Renamed from split_bbs_on_noreturn_calls. (cleanup_tree_cfg_1): Use split_bb_on_noreturn_calls. * tree-ssanames.h: Remove MODIFIED_NORETURN_CALLS. * gimple.h (enum gf_mask): Add GF_CALL_CTRL_ALTERING. (gimple_call_set_ctrl_altering): New func. (gimple_call_ctrl_altering_p): Ditto. * tree-cfg.c (gimple_call_initialize_ctrl_altering): Ditto. (make_blocks): Use gimple_call_initialize_ctrl_altering. (is_ctrl_altering_stmt): Use gimple_call_ctrl_altering_p. (execute_fixup_cfg): Use gimple_call_ctrl_altering_p and remove MODIFIED_NORETURN_CALLS. 2014-08-20 Martin Jambor <mjambor@suse.cz> Wei Mi <wmi@google.com> PR ipa/60449 PR middle-end/61776 * testsuite/gcc.dg/lto/pr60449_1.c: New test. * testsuite/gcc.dg/lto/pr60449_0.c: New test. * testsuite/gcc.dg/pr61776.c: New test. Modified: trunk/gcc/ChangeLog trunk/gcc/gimple.h trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-cfg.c trunk/gcc/tree-cfgcleanup.c trunk/gcc/tree-ssa-operands.c trunk/gcc/tree-ssanames.h
Author: wmi Date: Wed Aug 20 17:09:25 2014 New Revision: 214237 URL: https://gcc.gnu.org/viewcvs?rev=214237&root=gcc&view=rev Log: 2014-08-20 Martin Jambor <mjambor@suse.cz> Wei Mi <wmi@google.com> PR ipa/60449 PR middle-end/61776 * tree-ssa-operands.c (update_stmt_operands): Remove MODIFIED_NORETURN_CALLS. * tree-cfgcleanup.c (cleanup_call_ctrl_altering_flag): New func. (cleanup_control_flow_bb): Use cleanup_call_ctrl_altering_flag. (split_bb_on_noreturn_calls): Renamed from split_bbs_on_noreturn_calls. (cleanup_tree_cfg_1): Use split_bb_on_noreturn_calls. * tree-ssanames.h: Remove MODIFIED_NORETURN_CALLS. * gimple.h (enum gf_mask): Add GF_CALL_CTRL_ALTERING. (gimple_call_set_ctrl_altering): New func. (gimple_call_ctrl_altering_p): Ditto. * tree-cfg.c (gimple_call_initialize_ctrl_altering): Ditto. (make_blocks): Use gimple_call_initialize_ctrl_altering. (is_ctrl_altering_stmt): Use gimple_call_ctrl_altering_p. (execute_fixup_cfg): Use gimple_call_ctrl_altering_p and remove MODIFIED_NORETURN_CALLS. 2014-08-20 Martin Jambor <mjambor@suse.cz> Wei Mi <wmi@google.com> PR ipa/60449 PR middle-end/61776 * testsuite/gcc.dg/lto/pr60449_1.c: New test. * testsuite/gcc.dg/lto/pr60449_0.c: New test. * testsuite/gcc.dg/pr61776.c: New test. Added: branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/lto/pr60449_0.c branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/lto/pr60449_1.c branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/pr61776.c Modified: branches/gcc-4_9-branch/gcc/ChangeLog branches/gcc-4_9-branch/gcc/gimple.h branches/gcc-4_9-branch/gcc/testsuite/ChangeLog branches/gcc-4_9-branch/gcc/tree-cfg.c branches/gcc-4_9-branch/gcc/tree-cfgcleanup.c branches/gcc-4_9-branch/gcc/tree-ssa-operands.c branches/gcc-4_9-branch/gcc/tree-ssanames.h
GCC 4.9.2 has been released.
I believe this has been fixed. Thanks a lot by the way.