From 6e271009792ce0c070aad42d96032c38e9bd4aa3 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 23 Apr 2019 10:10:10 +0000 Subject: [PATCH] re PR debug/90131 (wrong debug info at -O3) 2019-04-23 Richard Biener PR debug/90131 * tree-cfgcleanup.c (move_debug_stmts_from_forwarder): Add dest_single_pred_p argument. (remove_forwarder_block): Adjust. (remove_forwarder_block_with_phi): Likewise. From-SVN: r270505 --- gcc/ChangeLog | 8 ++++++++ gcc/tree-cfgcleanup.c | 14 ++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 185cf518746..0823ca9bcfa 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2019-04-23 Richard Biener + + PR debug/90131 + * tree-cfgcleanup.c (move_debug_stmts_from_forwarder): Add + dest_single_pred_p argument. + (remove_forwarder_block): Adjust. + (remove_forwarder_block_with_phi): Likewise. + 2019-04-23 Ramana Radhakrishnan Bernd Edlinger Jakub Jelinek diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c index 0a79a6a658f..183b491ab1d 100644 --- a/gcc/tree-cfgcleanup.c +++ b/gcc/tree-cfgcleanup.c @@ -447,12 +447,12 @@ phi_alternatives_equal (basic_block dest, edge e1, edge e2) /* Move debug stmts from the forwarder block SRC to DEST. */ static void -move_debug_stmts_from_forwarder (basic_block src, basic_block dest) +move_debug_stmts_from_forwarder (basic_block src, basic_block dest, + bool dest_single_pred_p) { if (!MAY_HAVE_DEBUG_STMTS) return; - bool can_move_debug_stmts = single_pred_p (dest); gimple_stmt_iterator gsi_to = gsi_after_labels (dest); for (gimple_stmt_iterator gsi = gsi_after_labels (src); !gsi_end_p (gsi);) { @@ -460,7 +460,7 @@ move_debug_stmts_from_forwarder (basic_block src, basic_block dest) gcc_assert (is_gimple_debug (debug)); /* Move debug binds anyway, but not anything else like begin-stmt markers unless they are always valid at the destination. */ - if (can_move_debug_stmts + if (dest_single_pred_p || gimple_debug_bind_p (debug)) { gsi_move_before (&gsi, &gsi_to); @@ -472,7 +472,7 @@ move_debug_stmts_from_forwarder (basic_block src, basic_block dest) For anther, if the debug stmt is immediately followed by a (debug) definition in the destination (on a post-dominated path?) we can elide it without any bad effects. */ - if (!can_move_debug_stmts) + if (!dest_single_pred_p) { gimple_debug_bind_reset_value (debug); update_stmt (debug); @@ -544,6 +544,7 @@ remove_forwarder_block (basic_block bb) basic_block pred = NULL; if (single_pred_p (bb)) pred = single_pred (bb); + bool dest_single_pred_p = single_pred_p (dest); /* Redirect the edges. */ for (ei = ei_start (bb->preds); (e = ei_safe_edge (ei)); ) @@ -602,7 +603,7 @@ remove_forwarder_block (basic_block bb) /* Move debug statements. Reset them if the destination does not have a single predecessor. */ - move_debug_stmts_from_forwarder (bb, dest); + move_debug_stmts_from_forwarder (bb, dest, dest_single_pred_p); bitmap_set_bit (cfgcleanup_altered_bbs, dest->index); @@ -1203,6 +1204,7 @@ remove_forwarder_block_with_phi (basic_block bb) basic_block pred = NULL; if (single_pred_p (bb)) pred = single_pred (bb); + bool dest_single_pred_p = single_pred_p (dest); /* Redirect each incoming edge to BB to DEST. */ while (EDGE_COUNT (bb->preds) > 0) @@ -1287,7 +1289,7 @@ remove_forwarder_block_with_phi (basic_block bb) /* Move debug statements. Reset them if the destination does not have a single predecessor. */ - move_debug_stmts_from_forwarder (bb, dest); + move_debug_stmts_from_forwarder (bb, dest, dest_single_pred_p); /* Update the dominators. */ dombb = get_immediate_dominator (CDI_DOMINATORS, bb); -- 2.30.2