This is the mail archive of the gcc-patches@gcc.gnu.org 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 PR 40445: C++ ICE when using __builtin_unreachable() as only statement in a function.


The original message contained a totally unrelated patch. Attached is the correct patch (I hope).

David Daney wrote:
When we have:

const char * f (void)
{
  __builtint_unreachable();
}

rest_of_handle_eh() calls cleanup_cfg() and the empty first block of the function is removed. This causes havoc in several places, so I thought it best not to remove the first block at all in try_optimize_cfg().


Bootstrapped and regression tested with all default languages on x86_64-pc-linux-gnu with both -m32 and -m64. No regressions found.


OK to commit?

gcc/
2009-06-23  David Daney  <ddaney@caviumnetworks.com>

    PR rtl-optimization/40445
    * cfgcleanup.c (try_optimize_cfg): Don't remove the first block in
    a function.

gcc/testsuite
2009-06-23  David Daney  <ddaney@caviumnetworks.com>

    PR rtl-optimization/40445
    * g++.dg/other/builtin-unreachable-1.C: New testcase.


Index: testsuite/g++.dg/other/builtin-unreachable-1.C
===================================================================
--- testsuite/g++.dg/other/builtin-unreachable-1.C	(revision 0)
+++ testsuite/g++.dg/other/builtin-unreachable-1.C	(revision 0)
@@ -0,0 +1,11 @@
+// PR c++/40445
+// Check that a function containing only __builtin_unreachable()
+// doesn't ICE.
+
+// { dg-do compile }
+// { dg-options "-O0" }
+const char *
+f (void)
+{
+  __builtin_unreachable ();
+}
Index: cfgcleanup.c
===================================================================
--- cfgcleanup.c	(revision 148867)
+++ cfgcleanup.c	(working copy)
@@ -1903,7 +1903,8 @@ try_optimize_cfg (int mode)
 		  /* Note that forwarder_block_p true ensures that
 		     there is a successor for this block.  */
 		  && (single_succ_edge (b)->flags & EDGE_FALLTHRU)
-		  && n_basic_blocks > NUM_FIXED_BLOCKS + 1)
+		  && n_basic_blocks > NUM_FIXED_BLOCKS + 1
+		  && single_pred_edge (b)->src != ENTRY_BLOCK_PTR)
 		{
 		  if (dump_file)
 		    fprintf (dump_file,

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