From: Tom de Vries Date: Fri, 5 Feb 2021 09:36:38 +0000 (+0100) Subject: debug: fix switch lowering debug info X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4ede02a5f2af1205434f0e05aaaeff762b24e329;p=gcc.git debug: fix switch lowering debug info 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. --- 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 &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 &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. */