]> 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>
Fri, 5 Feb 2021 12:26:00 +0000 (13:26 +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.

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

index 24dbad93138f09b516888dbe8c5492dc1be87f0e..a4798812dbf0cd3523a0d51768ffda37476ccf2e 100644 (file)
@@ -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 ();
index d31fdf714276aed3cff8e668c7038f36545a49d0..d3d568e84cc74e5689047019a371594a82953f7e 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.  */
@@ -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.  */