Patchwork Don't ICE on deleted landing_pad labels during bb-reorder (PR rtl-optimization/50212)

login
register
mail settings
Submitter Jakub Jelinek
Date Aug. 29, 2011, 9:04 p.m.
Message ID <20110829210454.GF2687@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/112132/
State New
Headers show

Comments

Jakub Jelinek - Aug. 29, 2011, 9:04 p.m.
Hi!

As the following testcase shows, sometimes lp->landing_pad may be a
NOTE_DELETED_LABEL note and in that case
find_rarely_executed_basic_blocks_and_crossing_edges crashes.
for_each_eh_label in except.c does:
          rtx lab = lp->landing_pad;
          if (lab && LABEL_P (lab))
            (*callback) (lab);
so I think this isn't invalid and thus this patch does the same
during bb-reorder.  Bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk?

2011-08-29  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/50212
	* bb-reorder.c (find_rarely_executed_basic_blocks_and_crossing_edges):
	Skip also lps with NULL landing_pad or non-LABEL_P landing_pad.

	* g++.dg/other/pr50212.C: New test.


	Jakub

Patch

--- gcc/bb-reorder.c.jj	2011-07-25 11:28:32.000000000 +0200
+++ gcc/bb-reorder.c	2011-08-29 15:17:51.000000000 +0200
@@ -1,5 +1,5 @@ 
 /* Basic block reordering routines for the GNU compiler.
-   Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010
+   Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011
    Free Software Foundation, Inc.
 
    This file is part of GCC.
@@ -1315,7 +1315,9 @@  find_rarely_executed_basic_blocks_and_cr
 	{
 	  bool all_same, all_diff;
 
-	  if (lp == NULL)
+	  if (lp == NULL
+	      || lp->landing_pad == NULL_RTX
+	      || !LABEL_P (lp->landing_pad))
 	    continue;
 
 	  all_same = all_diff = true;
--- gcc/testsuite/g++.dg/other/pr50212.C.jj	2011-08-29 15:24:02.000000000 +0200
+++ gcc/testsuite/g++.dg/other/pr50212.C	2011-08-29 15:22:56.000000000 +0200
@@ -0,0 +1,17 @@ 
+// PR rtl-optimization/50212
+// { dg-do compile }
+// { dg-require-effective-target freorder }
+// { dg-options "-O -fnon-call-exceptions -ftrapv -freorder-blocks-and-partition" }
+
+void
+foo (int n)
+{
+  try
+  {
+    int i = 0;
+    while (i++ < n);
+  }
+  catch (...)
+  {
+  }
+}