Fix PR85455

Message ID alpine.LSU.2.20.1804191126490.31014@zhemvz.fhfr.qr
State New
Headers show
Series
  • Fix PR85455
Related show

Commit Message

Richard Biener April 19, 2018, 9:31 a.m.
This is an issue where clear_bb_flags clears BB_IRREDUCIBLE_LOOP and thus
wrecks loop info.  I'm not entirely sure what kind of flags we want
to clear (all uses would need to be audited I guess), the function isn't
used much either.  The following follows the function documentation
and adds BB_IRREDUCIBLE_LOOP to the preserved set if it has to be
preserved (rather than unconditionally).  From looking at cfg-flags.def
possibly BB_MODIFIED when df is active and BB_IN_TRANSACTIOn after
compute_transaction_bits () would need to be preserved as well.

Bootstrap & regtest running on x86_64-unknown-linux-gnu.

Does this look ok?

Thanks,
Richard.

2018-04-19  Richard Biener  <rguenther@suse.de>

	PR middle-end/85455
	* cfg.c (clear_bb_flags): When loop state says we have
	marked irreducible regions also preserve BB_IRREDUCIBLE_LOOP.

	* gcc.dg/pr85455.c: New testcase.

Patch

Index: gcc/cfg.c
===================================================================
--- gcc/cfg.c	(revision 259486)
+++ gcc/cfg.c	(working copy)
@@ -386,9 +386,13 @@  void
 clear_bb_flags (void)
 {
   basic_block bb;
+  int flags_to_preserve = BB_FLAGS_TO_PRESERVE;
+  if (current_loops
+      && loops_state_satisfies_p (cfun, LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS))
+    flags_to_preserve |= BB_IRREDUCIBLE_LOOP;
 
   FOR_ALL_BB_FN (bb, cfun)
-    bb->flags &= BB_FLAGS_TO_PRESERVE;
+    bb->flags &= flags_to_preserve;
 }
 
 /* Check the consistency of profile information.  We can't do that
Index: gcc/testsuite/gcc.dg/pr85455.c
===================================================================
--- gcc/testsuite/gcc.dg/pr85455.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/pr85455.c	(working copy)
@@ -0,0 +1,22 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O1 -fthread-jumps -fno-tree-dominator-opts -fno-tree-reassoc -fno-tree-sink -fno-tree-slsr" } */
+
+void
+ty (void);
+
+void
+um (void);
+
+void
+au (int qj)
+{
+  if (qj < 1)
+    {
+vq:
+      ty ();
+    }
+
+  um ();
+
+  goto vq;
+}