This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix ICE with __builtin_unreachable() as only statement in a function.

Richard Guenther wrote:
On Wed, Jun 17, 2009 at 9:33 AM, Paolo Bonzini<> wrote:
David Daney wrote:
This patch fixed an ICE I found doing additional __builtin_unreachable()

If __builtin_unreachable() is the only statement in a function, the
resulting barrier will be the first non-note insn when doing barrier
cleanup.  This causes SIGSEGV in cleanup_barriers.  The fix is to check for
NULL before dereferencing.
I think the comment is overkill here.  If somebody wonders what it's for,
svn blame plus the testcase will be more than enough to point him in the
right direction.

The patch is ok w/o the comment.

For the record, this is what I committed:

2009-06-17  David Daney  <>

	* jump.c (cleanup_barriers): Handle case of no insns before a

2009-06-17  David Daney  <>

* gcc.dg/builtin-unreachable-3.c: New test.

Index: testsuite/gcc.dg/builtin-unreachable-3.c =================================================================== --- testsuite/gcc.dg/builtin-unreachable-3.c (revision 0) +++ testsuite/gcc.dg/builtin-unreachable-3.c (revision 148624) @@ -0,0 +1,9 @@ +/* Check that a function containing only __builtin_unreachable() + doesn't ICE. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +const char * +f (void) +{ + __builtin_unreachable (); +} Index: jump.c =================================================================== --- jump.c (revision 148623) +++ jump.c (revision 148624) @@ -113,6 +113,8 @@ cleanup_barriers (void) if (BARRIER_P (insn)) { prev = prev_nonnote_insn (insn); + if (!prev) + continue; if (BARRIER_P (prev)) delete_insn (insn); else if (prev != PREV_INSN (insn))

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]