diff options
author | Richard Biener <rguenther@suse.de> | 2019-04-05 11:55:45 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2019-04-05 11:55:45 +0000 |
commit | 25eafae67f186cfa4c0fd0f89f743d7707d5bf21 (patch) | |
tree | f9f02b361b7c7daecd0478253904defd40599532 /gcc/tree-cfgcleanup.c | |
parent | 2723350fc6fd336768abd93e568babe032d97228 (diff) | |
download | gcc-25eafae67f186cfa4c0fd0f89f743d7707d5bf21.zip gcc-25eafae67f186cfa4c0fd0f89f743d7707d5bf21.tar.gz gcc-25eafae67f186cfa4c0fd0f89f743d7707d5bf21.tar.bz2 |
re PR debug/89892 (gcc generates wrong debug information at -O2)
2019-04-05 Richard Biener <rguenther@suse.de>
PR debug/89892
PR debug/89905
* tree-cfgcleanup.c (remove_forwarder_block): Always move
debug bind stmts but reset them if they are not valid at the
destination.
* gcc.dg/guality/pr89892.c: New testcase.
* gcc.dg/guality/pr89905.c: Likewise.
* gcc.dg/guality/loop-1.c: Likewise.
From-SVN: r270165
Diffstat (limited to 'gcc/tree-cfgcleanup.c')
-rw-r--r-- | gcc/tree-cfgcleanup.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c index f7bd565..3c291f5 100644 --- a/gcc/tree-cfgcleanup.c +++ b/gcc/tree-cfgcleanup.c @@ -564,15 +564,39 @@ remove_forwarder_block (basic_block bb) gsi_next (&gsi); } - /* Move debug statements if the destination has a single predecessor. */ - if (can_move_debug_stmts && !gsi_end_p (gsi)) + /* Move debug statements. Reset them if the destination does not + have a single predecessor. */ + if (!gsi_end_p (gsi)) { gsi_to = gsi_after_labels (dest); do { gimple *debug = gsi_stmt (gsi); gcc_assert (is_gimple_debug (debug)); - gsi_move_before (&gsi, &gsi_to); + /* 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 + || gimple_debug_bind_p (debug)) + { + gsi_move_before (&gsi, &gsi_to); + /* Reset debug-binds that are not always valid at the + destination. Simply dropping them can cause earlier + values to become live, generating wrong debug information. + ??? There are several things we could improve here. For + one we might be able to move stmts to the predecessor. + 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) + { + gimple_debug_bind_reset_value (debug); + update_stmt (debug); + } + } + else + gsi_next (&gsi); } while (!gsi_end_p (gsi)); } |