]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
debug: fix switch lowering debug info
authorTom de Vries <tdevries@suse.de>
Fri, 5 Feb 2021 09:36:38 +0000 (10:36 +0100)
committerMartin Liska <mliska@suse.cz>
Wed, 3 Mar 2021 08:57:28 +0000 (09:57 +0100)
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.

(cherry picked from commit 4ede02a5f2af1205434f0e05aaaeff762b24e329)

gcc/tree-switch-conversion.c
gcc/tree-switch-conversion.h

index 8da1be1cd99f463ec6c8455179cbe5774976e6ac..2bc098d0172f730858210154a730551896f00e86 100644 (file)
@@ -1115,7 +1115,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;
@@ -1134,6 +1135,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;
@@ -1858,7 +1860,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
@@ -1870,7 +1873,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 ();
index dbfd9eecba22c9091d0e3b6ebae8ec1912977283..1ff50fafaa3c32f813b07a878712505b1d6b9386 100644 (file)
@@ -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.  */
@@ -164,7 +164,7 @@ public:
     fprintf (f, " ");
   }
 
-  void emit (tree, tree, tree, basic_block)
+  void emit (tree, tree, tree, basic_block, location_t)
   {
     gcc_unreachable ();
   }
@@ -250,7 +250,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.  */
@@ -368,7 +368,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.  */