I'm sending Tom's patch that was approved by Jakub in the PR.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
I'm going to install it.

Thanks,
Martin

gcc/ChangeLog:

        PR debug/98656
        * tree-switch-conversion.c (jump_table_cluster::emit): Add loc
        argument.
        (bit_test_cluster::emit): Reuse location_t for newly created
        gswitch statement.
        (switch_decision_tree::try_switch_expansion): Preserve
        location_t.
        * tree-switch-conversion.h: Change function signatures.
---
 gcc/tree-switch-conversion.c | 11 +++++++----
 gcc/tree-switch-conversion.h |  8 ++++----
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index 24dbad93138..a4798812dbf 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -1112,7 +1112,8 @@ group_cluster::dump (FILE *f, bool details)
void
 jump_table_cluster::emit (tree index_expr, tree,
-                         tree default_label_expr, basic_block default_bb)
+                         tree default_label_expr, basic_block default_bb,
+                         location_t loc)
 {
   unsigned HOST_WIDE_INT range = get_range (get_low (), get_high ());
   unsigned HOST_WIDE_INT nondefault_range = 0;
@@ -1131,6 +1132,7 @@ jump_table_cluster::emit (tree index_expr, tree,
gswitch *s = gimple_build_switch (index_expr,
                                    unshare_expr (default_label_expr), labels);
+  gimple_set_location (s, loc);
   gimple_stmt_iterator gsi = gsi_start_bb (m_case_bb);
   gsi_insert_after (&gsi, s, GSI_NEW_STMT);
@@ -1491,7 +1493,7 @@ case_bit_test::cmp (const void *p1, const void *p2) void
 bit_test_cluster::emit (tree index_expr, tree index_type,
-                       tree, basic_block default_bb)
+                       tree, basic_block default_bb, location_t)
 {
   case_bit_test test[m_max_case_bit_tests] = { {} };
   unsigned int i, j, k;
@@ -1892,7 +1894,8 @@ switch_decision_tree::try_switch_expansion (vec<cluster *> 
&clusters)
     {
       cluster *c = clusters[0];
       c->emit (index_expr, index_type,
-              gimple_switch_default_label (m_switch), m_default_bb);
+              gimple_switch_default_label (m_switch), m_default_bb,
+              gimple_location (m_switch));
       redirect_edge_succ (single_succ_edge (bb), c->m_case_bb);
     }
   else
@@ -1904,7 +1907,7 @@ switch_decision_tree::try_switch_expansion (vec<cluster *> 
&clusters)
        if (clusters[i]->get_type () != SIMPLE_CASE)
          clusters[i]->emit (index_expr, index_type,
                             gimple_switch_default_label (m_switch),
-                            m_default_bb);
+                            m_default_bb, gimple_location (m_switch));
     }
fix_phi_operands_for_edges ();
diff --git a/gcc/tree-switch-conversion.h b/gcc/tree-switch-conversion.h
index d31fdf71427..d3d568e84cc 100644
--- a/gcc/tree-switch-conversion.h
+++ b/gcc/tree-switch-conversion.h
@@ -71,7 +71,7 @@ public:
   virtual void dump (FILE *f, bool details = false) = 0;
/* Emit GIMPLE code to handle the cluster. */
-  virtual void emit (tree, tree, tree, basic_block) = 0;
+  virtual void emit (tree, tree, tree, basic_block, location_t) = 0;
/* Return true if a cluster handles only a single case value and the
      value is not a range.  */
@@ -170,7 +170,7 @@ public:
     fprintf (f, " ");
   }
- void emit (tree, tree, tree, basic_block)
+  void emit (tree, tree, tree, basic_block, location_t)
   {
     gcc_unreachable ();
   }
@@ -260,7 +260,7 @@ public:
   }
void emit (tree index_expr, tree index_type,
-            tree default_label_expr, basic_block default_bb);
+            tree default_label_expr, basic_block default_bb, location_t loc);
/* Find jump tables of given CLUSTERS, where all members of the vector
      are of type simple_cluster.  New clusters are returned.  */
@@ -378,7 +378,7 @@ public:
     There *MUST* be max_case_bit_tests or less unique case
     node targets.  */
   void emit (tree index_expr, tree index_type,
-            tree default_label_expr, basic_block default_bb);
+            tree default_label_expr, basic_block default_bb, location_t loc);
/* Find bit tests of given CLUSTERS, where all members of the vector
      are of type simple_cluster.  New clusters are returned.  */
--
2.30.0

Reply via email to