Bug 53589 - [4.7/4.8 Regression] ICE in maybe_record_trace_start with asm goto
Summary: [4.7/4.8 Regression] ICE in maybe_record_trace_start with asm goto
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.7.2
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2012-06-06 12:53 UTC by Jakub Jelinek
Modified: 2024-09-04 17:44 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work: 4.6.2
Known to fail: 4.7.0, 4.8.0
Last reconfirmed: 2012-06-06 00:00:00


Attachments
gcc48-pr53589.patch (876 bytes, patch)
2012-06-06 13:16 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2012-06-06 12:53:13 UTC
extern void foo (void) __attribute__ ((__noreturn__));

void
bar (int x)
{
  if (x < 0)
    foo ();
  if (x == 0)
    return;
  __asm goto ("" : : : : lab);
lab:;
}

ICEs on x86_64-linux:
LC_ALL=C ./cc1 -O2 rh829247.c -quiet
rh829247.c: In function 'bar':
rh829247.c:12:1: internal compiler error: in maybe_record_trace_start, at dwarf2cfi.c:2193
 }
 ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

The problem is that we end up with asm goto that branches to the fallthru label and shrink-wrapping wants to redirect the edge, but leaves broken CFG around.
Comment 1 Jakub Jelinek 2012-06-06 13:11:30 UTC
Started with -fshrink-wrap addition http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179553
Comment 2 Jakub Jelinek 2012-06-06 13:16:53 UTC
Created attachment 27562 [details]
gcc48-pr53589.patch

Untested fix.
Comment 3 Jakub Jelinek 2012-06-12 07:52:53 UTC
Author: jakub
Date: Tue Jun 12 07:52:47 2012
New Revision: 188428

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188428
Log:
	PR rtl-optimization/53589
	* cfgrtl.c (force_nonfallthru_and_redirect): Do asm_goto_edge
	discovery even when e->dest != target.  If any LABEL_REF points
	to e->dest label, redirect it to target's label.

	* gcc.dg/torture/pr53589.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr53589.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cfgrtl.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Richard Biener 2012-06-14 08:42:18 UTC
GCC 4.7.1 is being released, adjusting target milestone.
Comment 5 Jakub Jelinek 2012-06-14 17:49:54 UTC
Author: jakub
Date: Thu Jun 14 17:49:49 2012
New Revision: 188626

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188626
Log:
	Backported from mainline
	2012-06-12  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/53589
	* cfgrtl.c (force_nonfallthru_and_redirect): Do asm_goto_edge
	discovery even when e->dest != target.  If any LABEL_REF points
	to e->dest label, redirect it to target's label.

	* gcc.dg/torture/pr53589.c: New test.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/gcc.dg/torture/pr53589.c
Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/cfgrtl.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
Comment 6 Jakub Jelinek 2012-06-15 11:10:45 UTC
Fixed.