]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* rtl.h (locator_eq): New decl.
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 9 Oct 2008 20:04:10 +0000 (20:04 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 9 Oct 2008 20:04:10 +0000 (20:04 +0000)
* cfglayout.c (locator_scope): New function.
(insn_scope): Use it.
(locator_eq): New function.
(fixup_reorder_chain): Search for last insn in src bb
that has locator set or first insn in dest bb.  Use
locator_eq instead of == to compare locators.
* cfgrtl.c (cfg_layout_merge_blocks): Likewise.
* cfgcleanup.c (try_forward_edges): Use locator_eq instead of
== to compare locators.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141009 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cfgcleanup.c
gcc/cfglayout.c
gcc/cfgrtl.c
gcc/rtl.h

index 8e9648ae0616621614c0a23424e8d14e9d6db6b1..fc48767f83a8470f782457c02fdee14569de9762 100644 (file)
@@ -1,5 +1,16 @@
 2008-10-09  Jakub Jelinek  <jakub@redhat.com>
 
+       * rtl.h (locator_eq): New decl.
+       * cfglayout.c (locator_scope): New function.
+       (insn_scope): Use it.
+       (locator_eq): New function.
+       (fixup_reorder_chain): Search for last insn in src bb
+       that has locator set or first insn in dest bb.  Use
+       locator_eq instead of == to compare locators.
+       * cfgrtl.c (cfg_layout_merge_blocks): Likewise.
+       * cfgcleanup.c (try_forward_edges): Use locator_eq instead of
+       == to compare locators.
+
        * tree-ssa-live.c (remove_unused_locals): Mark all edge's goto_block
        as used.
        * gimple-low.c (lower_function_body, lower_gimple_return,
index 8b9756def217439d7a4a5b654509cdc48a58bda0..190bde668481205edee329e4c65fd145e6fa9ce2 100644 (file)
@@ -483,7 +483,7 @@ try_forward_edges (int mode, basic_block b)
                     blocks with different locus are not optimized out.  */
                  int locus = single_succ_edge (target)->goto_locus;
 
-                 if (locus && goto_locus && locus != goto_locus)
+                 if (locus && goto_locus && !locator_eq (locus, goto_locus))
                    counter = n_basic_blocks;
                  else if (locus)
                    goto_locus = locus;
@@ -492,7 +492,8 @@ try_forward_edges (int mode, basic_block b)
                    {
                      locus = INSN_LOCATOR (BB_END (target));
 
-                     if (locus && goto_locus && locus != goto_locus)
+                     if (locus && goto_locus
+                         && !locator_eq (locus, goto_locus))
                        counter = n_basic_blocks;
                      else if (locus)
                        goto_locus = locus;
index be1188d0b615ef2c77910f29a6b5cbd351987ae4..05e355d411f1fc429ad2c7bf4b15f9c0339f878a 100644 (file)
@@ -448,13 +448,12 @@ change_scope (rtx orig_insn, tree s1, tree s2)
     }
 }
 
-/* Return lexical scope block insn belong to.  */
+/* Return lexical scope block locator belongs to.  */
 static tree
-insn_scope (const_rtx insn)
+locator_scope (int loc)
 {
   int max = VEC_length (int, block_locators_locs);
   int min = 0;
-  int loc = INSN_LOCATOR (insn);
 
   /* When block_locators_locs was initialized, the pro- and epilogue
      insns didn't exist yet and can therefore not be found this way.
@@ -488,6 +487,13 @@ insn_scope (const_rtx insn)
   return VEC_index (tree, block_locators_blocks, min);
 }
 
+/* Return lexical scope block insn belongs to.  */
+static tree
+insn_scope (const_rtx insn)
+{
+  return locator_scope (INSN_LOCATOR (insn));
+}
+
 /* Return line number of the statement specified by the locator.  */
 static location_t
 locator_location (int loc)
@@ -551,6 +557,17 @@ insn_file (const_rtx insn)
   return locator_file (INSN_LOCATOR (insn));
 }
 
+/* Return true if LOC1 and LOC2 locators have the same location and scope.  */
+bool
+locator_eq (int loc1, int loc2)
+{
+  if (loc1 == loc2)
+    return true;
+  if (locator_location (loc1) != locator_location (loc2))
+    return false;
+  return locator_scope (loc1) == locator_scope (loc2);
+}
+
 /* Rebuild all the NOTE_INSN_BLOCK_BEG and NOTE_INSN_BLOCK_END notes based
    on the scope tree and the newly reordered instructions.  */
 
@@ -900,24 +917,30 @@ fixup_reorder_chain (void)
          if (e->goto_locus && !(e->flags & EDGE_ABNORMAL))
            {
              basic_block nb;
-
-             if (simplejump_p (BB_END (e->src)))
+             rtx end;
+
+             insn = BB_END (e->src);
+             end = PREV_INSN (BB_HEAD (e->src));
+             while (insn != end
+                    && (!INSN_P (insn) || INSN_LOCATOR (insn) == 0))
+               insn = PREV_INSN (insn);
+             if (insn != end
+                 && locator_eq (INSN_LOCATOR (insn), (int) e->goto_locus))
+               continue;
+             if (simplejump_p (BB_END (e->src))
+                 && INSN_LOCATOR (BB_END (e->src)) == 0)
                {
-                 if (INSN_LOCATOR (BB_END (e->src)) == (int) e->goto_locus)
-                   continue;
-                 if (INSN_LOCATOR (BB_END (e->src)) == 0)
-                   {
-                     INSN_LOCATOR (BB_END (e->src)) = e->goto_locus;
-                     continue;
-                   }
+                 INSN_LOCATOR (BB_END (e->src)) = e->goto_locus;
+                 continue;
                }
              if (e->dest != EXIT_BLOCK_PTR)
                {
                  insn = BB_HEAD (e->dest);
-                 if (!INSN_P (insn))
-                   insn = next_insn (insn);
-                 if (insn && INSN_P (insn)
-                     && INSN_LOCATOR (insn) == (int) e->goto_locus)
+                 end = NEXT_INSN (BB_END (e->dest));
+                 while (insn != end && !INSN_P (insn))
+                   insn = NEXT_INSN (insn);
+                 if (insn != end && INSN_LOCATOR (insn)
+                     && locator_eq (INSN_LOCATOR (insn), (int) e->goto_locus))
                    continue;
                }
              nb = split_edge (e);
index 24469ebf30de3f28508ba55aa5024ea0512cb884..a7dc5076865fdc0d76a4f5e3223256ef334d8366 100644 (file)
@@ -2615,19 +2615,21 @@ cfg_layout_merge_blocks (basic_block a, basic_block b)
      some unique locus, emit a nop with that locus in between.  */
   if (!optimize && EDGE_SUCC (a, 0)->goto_locus)
     {
-      rtx insn = BB_END (a);
+      rtx insn = BB_END (a), end = PREV_INSN (BB_HEAD (a));
       int goto_locus = EDGE_SUCC (a, 0)->goto_locus;
 
-      if (NOTE_P (insn))
-       insn = prev_nonnote_insn (insn);
-      if (insn && INSN_P (insn) && INSN_LOCATOR (insn) == goto_locus)
+      while (insn != end && (!INSN_P (insn) || INSN_LOCATOR (insn) == 0))
+       insn = PREV_INSN (insn);
+      if (insn != end && locator_eq (INSN_LOCATOR (insn), goto_locus))
        goto_locus = 0;
       else
        {
          insn = BB_HEAD (b);
-         if (!INSN_P (insn))
-           insn = next_insn (insn);
-         if (insn && INSN_P (insn) && INSN_LOCATOR (insn) == goto_locus)
+         end = NEXT_INSN (BB_END (b));
+         while (insn != end && !INSN_P (insn))
+           insn = NEXT_INSN (insn);
+         if (insn != end && INSN_LOCATOR (insn) != 0
+             && locator_eq (INSN_LOCATOR (insn), goto_locus))
            goto_locus = 0;
        }
       if (goto_locus)
index fd855e9c6500c2f6e5c14f126271651ce303c8a0..118025a4ff06e5d2225d2110c93335d20ca883fa 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -1639,6 +1639,7 @@ extern int insn_line (const_rtx);
 extern const char * insn_file (const_rtx);
 extern int locator_line (int);
 extern const char * locator_file (int);
+extern bool locator_eq (int, int);
 extern int prologue_locator, epilogue_locator;
 
 /* In jump.c */