aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-outof-ssa.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2019-07-05 08:39:13 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2019-07-05 08:39:13 +0000
commit4500f7510368cdb24b8afcc66e86e09cafe49199 (patch)
treeef2fbd634046ad09eee8adc6a72055247524803a /gcc/tree-outof-ssa.c
parentffdc40a90faec54d29af76b994c52790685a8e58 (diff)
downloadgcc-4500f7510368cdb24b8afcc66e86e09cafe49199.zip
gcc-4500f7510368cdb24b8afcc66e86e09cafe49199.tar.gz
gcc-4500f7510368cdb24b8afcc66e86e09cafe49199.tar.bz2
except.c (emit_to_new_bb_before): Make sure to put a location on SEQ.
* except.c (emit_to_new_bb_before): Make sure to put a location on SEQ. * tree-eh.c (replace_goto_queue_1) <GIMPLE_GOTO>: Propagate location. (emit_eh_dispatch): Delete. (lower_catch): Emit the eh_dispatch manually and set the location of the first catch statement onto it. (lower_eh_filter): Emit the eh_dispatch manually and set location. (lower_eh_dispatch): Propagate location. * tree-outof-ssa.c (set_location_for_edge): Handle EH edges specially. (eliminate_build): Likewise. From-SVN: r273132
Diffstat (limited to 'gcc/tree-outof-ssa.c')
-rw-r--r--gcc/tree-outof-ssa.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c
index 713b0b0..d8c8249 100644
--- a/gcc/tree-outof-ssa.c
+++ b/gcc/tree-outof-ssa.c
@@ -171,14 +171,43 @@ struct elim_graph
use its location. Otherwise search instructions in predecessors
of E for a location, and use that one. That makes sense because
we insert on edges for PHI nodes, and effects of PHIs happen on
- the end of the predecessor conceptually. */
+ the end of the predecessor conceptually. An exception is made
+ for EH edges because we don't want to drag the source location
+ of unrelated statements at the beginning of handlers; they would
+ be further reused for various EH constructs, which would damage
+ the coverage information. */
static void
set_location_for_edge (edge e)
{
if (e->goto_locus)
+ set_curr_insn_location (e->goto_locus);
+ else if (e->flags & EDGE_EH)
{
- set_curr_insn_location (e->goto_locus);
+ basic_block bb = e->dest;
+ gimple_stmt_iterator gsi;
+
+ do
+ {
+ for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+ {
+ gimple *stmt = gsi_stmt (gsi);
+ if (is_gimple_debug (stmt))
+ continue;
+ if (gimple_has_location (stmt) || gimple_block (stmt))
+ {
+ set_curr_insn_location (gimple_location (stmt));
+ return;
+ }
+ }
+ /* Nothing found in this basic block. Make a half-assed attempt
+ to continue with another block. */
+ if (single_succ_p (bb))
+ bb = single_succ (bb);
+ else
+ bb = e->dest;
+ }
+ while (bb != e->dest);
}
else
{
@@ -564,7 +593,11 @@ eliminate_build (elim_graph *g)
continue;
Ti = PHI_ARG_DEF (phi, g->e->dest_idx);
- locus = gimple_phi_arg_location_from_edge (phi, g->e);
+ /* See set_location_for_edge for the rationale. */
+ if (g->e->flags & EDGE_EH)
+ locus = UNKNOWN_LOCATION;
+ else
+ locus = gimple_phi_arg_location_from_edge (phi, g->e);
/* If this argument is a constant, or a SSA_NAME which is being
left in SSA form, just queue a copy to be emitted on this