aboutsummaryrefslogtreecommitdiff
path: root/gcc/cfgrtl.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2008-10-07 20:48:40 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2008-10-07 20:48:40 +0200
commit7241571ec8f99caff65f266d3ce395cb0eadb59c (patch)
tree03f51a3cfb0818209eab45192a2bd9ce8a4fa7c4 /gcc/cfgrtl.c
parentaee857a2f4fbbcf0d3fde1d80c8c40d53b5edab1 (diff)
downloadgcc-7241571ec8f99caff65f266d3ce395cb0eadb59c.zip
gcc-7241571ec8f99caff65f266d3ce395cb0eadb59c.tar.gz
gcc-7241571ec8f99caff65f266d3ce395cb0eadb59c.tar.bz2
re PR middle-end/29609 (Even with -O0 -g gcc optimizes a goto away and I cannot debug)
PR debug/29609 PR debug/36690 PR debug/37616 * basic-block.h (struct edge_def): Add goto_block field. * cfglayout.c (fixup_reorder_chain): Ensure that there is at least one insn with locus corresponding to edge's goto_locus if !optimize. * profile.c (branch_prob): Copy edge's goto_block. * cfgrtl.c (force_nonfallthru_and_redirect): Use goto_locus for emitted jumps. (cfg_layout_merge_blocks): Emit a nop with edge's goto_locus locator in between the merged basic blocks if !optimize and needed. * cfgexpand.c (expand_gimple_cond): Convert goto_block and goto_locus into RTL locator. For unconditional jump use that locator for the jump insn. (expand_gimple_cond): Convert goto_block and goto_locus into RTL locator for all remaining edges. For unconditional jump use that locator for the jump insn. * cfgcleanup.c (try_forward_edges): Avoid the optimization if there is more than one edge or insn locator along the forwarding edges and !optimize. If there is just one, set e->goto_locus. * tree-cfg.c (make_cond_expr_edges, make_goto_expr_edges): Set also edge's goto_block. (move_block_to_fn): Adjust edge's goto_block. * gcc.dg/debug/pr29609-1.c: New test. * gcc.dg/debug/pr29609-2.c: New test. * gcc.dg/debug/pr36690-1.c: New test. * gcc.dg/debug/pr36690-2.c: New test. * gcc.dg/debug/pr36690-3.c: New test. * gcc.dg/debug/pr37616.c: New test. * gcc.dg/debug/dwarf2/pr29609-1.c: New test. * gcc.dg/debug/dwarf2/pr29609-2.c: New test. * gcc.dg/debug/dwarf2/pr36690-1.c: New test. * gcc.dg/debug/dwarf2/pr36690-2.c: New test. * gcc.dg/debug/dwarf2/pr36690-3.c: New test. * gcc.dg/debug/dwarf2/pr37616.c: New test. From-SVN: r140948
Diffstat (limited to 'gcc/cfgrtl.c')
-rw-r--r--gcc/cfgrtl.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index f9e3e17..24469eb 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -1009,6 +1009,7 @@ force_nonfallthru_and_redirect (edge e, basic_block target)
rtx note;
edge new_edge;
int abnormal_edge_flags = 0;
+ int loc;
/* In the case the last instruction is conditional jump to the next
instruction, first redirect the jump itself and then continue
@@ -1127,11 +1128,15 @@ force_nonfallthru_and_redirect (edge e, basic_block target)
else
jump_block = e->src;
+ if (e->goto_locus && e->goto_block == NULL)
+ loc = e->goto_locus;
+ else
+ loc = 0;
e->flags &= ~EDGE_FALLTHRU;
if (target == EXIT_BLOCK_PTR)
{
#ifdef HAVE_return
- emit_jump_insn_after_noloc (gen_return (), BB_END (jump_block));
+ emit_jump_insn_after_setloc (gen_return (), BB_END (jump_block), loc);
#else
gcc_unreachable ();
#endif
@@ -1139,7 +1144,7 @@ force_nonfallthru_and_redirect (edge e, basic_block target)
else
{
rtx label = block_label (target);
- emit_jump_insn_after_noloc (gen_jump (label), BB_END (jump_block));
+ emit_jump_insn_after_setloc (gen_jump (label), BB_END (jump_block), loc);
JUMP_LABEL (BB_END (jump_block)) = label;
LABEL_NUSES (label)++;
}
@@ -2606,6 +2611,32 @@ cfg_layout_merge_blocks (basic_block a, basic_block b)
try_redirect_by_replacing_jump (EDGE_SUCC (a, 0), b, true);
gcc_assert (!JUMP_P (BB_END (a)));
+ /* When not optimizing and the edge is the only place in RTL which holds
+ some unique locus, emit a nop with that locus in between. */
+ if (!optimize && EDGE_SUCC (a, 0)->goto_locus)
+ {
+ rtx insn = BB_END (a);
+ int goto_locus = EDGE_SUCC (a, 0)->goto_locus;
+
+ if (NOTE_P (insn))
+ insn = prev_nonnote_insn (insn);
+ if (insn && INSN_P (insn) && INSN_LOCATOR (insn) == goto_locus)
+ goto_locus = 0;
+ else
+ {
+ insn = BB_HEAD (b);
+ if (!INSN_P (insn))
+ insn = next_insn (insn);
+ if (insn && INSN_P (insn) && INSN_LOCATOR (insn) == goto_locus)
+ goto_locus = 0;
+ }
+ if (goto_locus)
+ {
+ BB_END (a) = emit_insn_after_noloc (gen_nop (), BB_END (a), a);
+ INSN_LOCATOR (BB_END (a)) = goto_locus;
+ }
+ }
+
/* Possible line number notes should appear in between. */
if (b->il.rtl->header)
{