From: Trevor Saunders <tbsaunde+...@tbsaunde.org>

gcc/ChangeLog:

2016-04-20  Trevor Saunders  <tbsaunde+...@tbsaunde.org>

        * cfgbuild.c (make_edges): Adjust.
        * cfgrtl.c (can_delete_label_p): Likewise.
        * dwarf2cfi.c (create_trace_edges): Likewise.
        * except.c (sjlj_emit_dispatch_table): Likewise.
        * function.h (struct expr_status): make x_forced_labels a vector.
        * jump.c (rebuild_jump_labels_1): Adjust.
        * reload1.c (set_initial_label_offsets): Likewise.
        * stmt.c (force_label_rtx): Likewise.
        (expand_label): Likewise.
---
 gcc/cfgbuild.c  |  9 ++++++---
 gcc/cfgrtl.c    |  3 ++-
 gcc/dwarf2cfi.c |  6 ++++--
 gcc/except.c    |  3 +--
 gcc/function.h  |  2 +-
 gcc/jump.c      | 12 +++++++-----
 gcc/reload1.c   |  9 ++++-----
 gcc/stmt.c      |  4 ++--
 8 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/gcc/cfgbuild.c b/gcc/cfgbuild.c
index bffb07b..5449a53 100644
--- a/gcc/cfgbuild.c
+++ b/gcc/cfgbuild.c
@@ -204,7 +204,8 @@ make_edges (basic_block min, basic_block max, int update_p)
   /* Heavy use of computed goto in machine-generated code can lead to
      nearly fully-connected CFGs.  In that case we spend a significant
      amount of time searching the edge lists for duplicates.  */
-  if (forced_labels || cfun->cfg->max_jumptable_ents > 100)
+  if (!vec_safe_is_empty (forced_labels)
+      || cfun->cfg->max_jumptable_ents > 100)
     edge_cache = sbitmap_alloc (last_basic_block_for_fn (cfun));
 
   /* By nature of the way these get numbered, ENTRY_BLOCK_PTR->next_bb block
@@ -280,8 +281,10 @@ make_edges (basic_block min, basic_block max, int update_p)
             everything on the forced_labels list.  */
          else if (computed_jump_p (insn))
            {
-             for (rtx_insn_list *x = forced_labels; x; x = x->next ())
-               make_label_edge (edge_cache, bb, x->insn (), EDGE_ABNORMAL);
+             rtx_insn *insn;
+             unsigned int i;
+             FOR_EACH_VEC_SAFE_ELT_REVERSE (forced_labels, i, insn)
+               make_label_edge (edge_cache, bb, insn, EDGE_ABNORMAL);
            }
 
          /* Returns create an exit out.  */
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index 7cfc634..f4a9244 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -115,7 +115,8 @@ can_delete_label_p (const rtx_code_label *label)
   return (!LABEL_PRESERVE_P (label)
          /* User declared labels must be preserved.  */
          && LABEL_NAME (label) == 0
-         && !in_insn_list_p (forced_labels, label));
+         && !vec_safe_contains<rtx_insn *> (forced_labels,
+                                            const_cast<rtx_code_label *> 
(label)));
 }
 
 /* Delete INSN by patching it out.  */
diff --git a/gcc/dwarf2cfi.c b/gcc/dwarf2cfi.c
index 6180da4..2149c58 100644
--- a/gcc/dwarf2cfi.c
+++ b/gcc/dwarf2cfi.c
@@ -2354,8 +2354,10 @@ create_trace_edges (rtx_insn *insn)
        }
       else if (computed_jump_p (insn))
        {
-         for (rtx_insn_list *lab = forced_labels; lab; lab = lab->next ())
-           maybe_record_trace_start (lab->insn (), insn);
+         rtx_insn *temp;
+         unsigned int i;
+         FOR_EACH_VEC_SAFE_ELT_REVERSE (forced_labels, i, temp)
+           maybe_record_trace_start (temp, insn);
        }
       else if (returnjump_p (insn))
        ;
diff --git a/gcc/except.c b/gcc/except.c
index cf1df8c..97f5e6a 100644
--- a/gcc/except.c
+++ b/gcc/except.c
@@ -1278,8 +1278,7 @@ sjlj_emit_dispatch_table (rtx_code_label *dispatch_label, 
int num_dispatch)
      label on the nonlocal_goto_label list.  Since we're modeling these
      CFG edges more exactly, we can use the forced_labels list instead.  */
   LABEL_PRESERVE_P (dispatch_label) = 1;
-  forced_labels
-    = gen_rtx_INSN_LIST (VOIDmode, dispatch_label, forced_labels);
+  vec_safe_push<rtx_insn *> (forced_labels, dispatch_label);
 #endif
 
   /* Load up exc_ptr and filter values from the function context.  */
diff --git a/gcc/function.h b/gcc/function.h
index 501ef68..590a490 100644
--- a/gcc/function.h
+++ b/gcc/function.h
@@ -126,7 +126,7 @@ struct GTY(()) expr_status {
   rtx x_apply_args_value;
 
   /* List of labels that must never be deleted.  */
-  rtx_insn_list *x_forced_labels;
+  vec<rtx_insn *, va_gc> *x_forced_labels;
 };
 
 typedef struct call_site_record_d *call_site_record;
diff --git a/gcc/jump.c b/gcc/jump.c
index 5b433af..b166926 100644
--- a/gcc/jump.c
+++ b/gcc/jump.c
@@ -68,8 +68,6 @@ static int invert_exp_1 (rtx, rtx);
 static void
 rebuild_jump_labels_1 (rtx_insn *f, bool count_forced)
 {
-  rtx_insn_list *insn;
-
   timevar_push (TV_REBUILD_JUMP);
   init_label_info (f);
   mark_all_labels (f);
@@ -79,9 +77,13 @@ rebuild_jump_labels_1 (rtx_insn *f, bool count_forced)
      count doesn't drop to zero.  */
 
   if (count_forced)
-    for (insn = forced_labels; insn; insn = insn->next ())
-      if (LABEL_P (insn->insn ()))
-       LABEL_NUSES (insn->insn ())++;
+    {
+      rtx_insn *insn;
+      unsigned int i;
+      FOR_EACH_VEC_SAFE_ELT_REVERSE (forced_labels, i, insn)
+       if (LABEL_P (insn))
+         LABEL_NUSES (insn)++;
+    }
   timevar_pop (TV_REBUILD_JUMP);
 }
 
diff --git a/gcc/reload1.c b/gcc/reload1.c
index 770bf40..0017eac 100644
--- a/gcc/reload1.c
+++ b/gcc/reload1.c
@@ -3873,12 +3873,11 @@ set_initial_label_offsets (void)
 {
   memset (offsets_known_at, 0, num_labels);
 
-  for (rtx_insn_list *x = forced_labels; x; x = x->next ())
-    if (x->insn ())
-      set_label_offsets (x->insn (), NULL, 1);
-
-  rtx_insn *insn;
   unsigned int i;
+  rtx_insn *insn;
+  FOR_EACH_VEC_SAFE_ELT_REVERSE (forced_labels, i, insn)
+    set_label_offsets (insn, NULL, 1);
+
   FOR_EACH_VEC_SAFE_ELT_REVERSE (nonlocal_goto_handler_labels, i, insn)
       set_label_offsets (insn, NULL, 1);
 
diff --git a/gcc/stmt.c b/gcc/stmt.c
index a6612fc..852cdb5 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -136,7 +136,7 @@ force_label_rtx (tree label)
 
   gcc_assert (function);
 
-  forced_labels = gen_rtx_INSN_LIST (VOIDmode, ref, forced_labels);
+  vec_safe_push (forced_labels, ref);
   return ref;
 }
 
@@ -188,7 +188,7 @@ expand_label (tree label)
     }
 
   if (FORCED_LABEL (label))
-    forced_labels = gen_rtx_INSN_LIST (VOIDmode, label_r, forced_labels);
+    vec_safe_push<rtx_insn *> (forced_labels, label_r);
 
   if (DECL_NONLOCAL (label) || FORCED_LABEL (label))
     maybe_set_first_label_num (label_r);
-- 
2.7.4

Reply via email to