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]

[PATCH] Update crtl->has_bb_partition if NOTE_INSN_SWITCH_SECTIONS isn't emitted (PR debug/83585)


Hi!

My recent dwarf2out.c, dbxout.c and rs6000.c uses of crtl->has_bb_partition
all assume that if it is true then the function actually has 2 partitions
and NOTE_INSN_SWITCH_SECTIONS is present, but as the following testcase
shows, that isn't always the case, crtl->has_bb_partition is set during
bbpart pass if there are 2 partitions, but there are many passes in between
and all bbs of one of the partitions could be optimized away.

Are there any uses of this flag that would be interested in whether the
function had any partitions in the past (I guess that also means
BB_PARTITION is not unspecified), rather than whether the function has 2
partitions right now?  If yes, instead of this patch we could introduce
a new flag in cfun set by insert_section_boundary_note.  If not, the
following patch should be sufficient.

Bootstrapped/regtested on x86_64-linux and i686-linux.

2018-01-03  Jakub Jelinek  <jakub@redhat.com>

	PR debug/83585
	* bb-reorder.c (insert_section_boundary_note): Set has_bb_partition
	to switched_sections.

	* gcc.dg/pr83585.c: New test.

--- gcc/bb-reorder.c.jj	2018-01-03 10:19:55.303533981 +0100
+++ gcc/bb-reorder.c	2018-01-03 18:16:32.470555769 +0100
@@ -2523,6 +2523,11 @@ insert_section_boundary_note (void)
           current_partition = BB_PARTITION (bb);
 	}
     }
+
+  /* Make sure crtl->has_bb_partition matches reality even if bbpart finds
+     some hot and some cold basic blocks, but later one of those kinds is
+     optimized away.  */
+  crtl->has_bb_partition = switched_sections;
 }
 
 namespace {
--- gcc/testsuite/gcc.dg/pr83585.c.jj	2018-01-03 18:20:33.685641817 +0100
+++ gcc/testsuite/gcc.dg/pr83585.c	2018-01-03 18:19:29.922619064 +0100
@@ -0,0 +1,18 @@
+/* PR debug/83585 */
+/* { dg-do assemble } */
+/* { dg-options "-std=gnu89 -O2 -g -fno-tree-dce -fno-guess-branch-probability" } */
+
+int
+foo (int x)
+{
+  int a, b;
+  for (a = 0; a < 2; ++a)
+    if (x != 0)
+      {
+        for (b = 0; b < 2; ++b)
+          ;
+        return 0;
+      }
+
+  return;
+}

	Jakub


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