aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-inline.c
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2015-06-09 05:05:12 +0000
committerAlexandre Oliva <aoliva@gcc.gnu.org>2015-06-09 05:05:12 +0000
commitf79c81b920e70f16e67fa0eabf35ade358e5d3da (patch)
treeab4051301aab82b9f84a62a7932e4c89b683a7be /gcc/tree-inline.c
parent04fb9539b76106df895e9b95c345ffd7dbff76cd (diff)
downloadgcc-f79c81b920e70f16e67fa0eabf35ade358e5d3da.zip
gcc-f79c81b920e70f16e67fa0eabf35ade358e5d3da.tar.gz
gcc-f79c81b920e70f16e67fa0eabf35ade358e5d3da.tar.bz2
Reset inlined debug variables at the end of the inlined function
for gcc/ChangeLog PR debug/58315 * tree-inline.c (reset_debug_binding): New. (reset_debug_bindings): Likewise. (expand_call_inline): Call it. From-SVN: r224261
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r--gcc/tree-inline.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 46a5f8d..242026c 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -4335,6 +4335,60 @@ add_local_variables (struct function *callee, struct function *caller,
}
}
+/* Add to BINDINGS a debug stmt resetting SRCVAR if inlining might
+ have brought in or introduced any debug stmts for SRCVAR. */
+
+static inline void
+reset_debug_binding (copy_body_data *id, tree srcvar, gimple_seq *bindings)
+{
+ tree *remappedvarp = id->decl_map->get (srcvar);
+
+ if (!remappedvarp)
+ return;
+
+ if (TREE_CODE (*remappedvarp) != VAR_DECL)
+ return;
+
+ if (*remappedvarp == id->retvar || *remappedvarp == id->retbnd)
+ return;
+
+ tree tvar = target_for_debug_bind (*remappedvarp);
+ if (!tvar)
+ return;
+
+ gdebug *stmt = gimple_build_debug_bind (tvar, NULL_TREE,
+ id->call_stmt);
+ gimple_seq_add_stmt (bindings, stmt);
+}
+
+/* For each inlined variable for which we may have debug bind stmts,
+ add before GSI a final debug stmt resetting it, marking the end of
+ its life, so that var-tracking knows it doesn't have to compute
+ further locations for it. */
+
+static inline void
+reset_debug_bindings (copy_body_data *id, gimple_stmt_iterator gsi)
+{
+ tree var;
+ unsigned ix;
+ gimple_seq bindings = NULL;
+
+ if (!gimple_in_ssa_p (id->src_cfun))
+ return;
+
+ if (!opt_for_fn (id->dst_fn, flag_var_tracking_assignments))
+ return;
+
+ for (var = DECL_ARGUMENTS (id->src_fn);
+ var; var = DECL_CHAIN (var))
+ reset_debug_binding (id, var, &bindings);
+
+ FOR_EACH_LOCAL_DECL (id->src_cfun, ix, var)
+ reset_debug_binding (id, var, &bindings);
+
+ gsi_insert_seq_before_without_update (&gsi, bindings, GSI_SAME_STMT);
+}
+
/* If STMT is a GIMPLE_CALL, replace it with its inline expansion. */
static bool
@@ -4648,6 +4702,8 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id)
GCOV_COMPUTE_SCALE (cg_edge->frequency, CGRAPH_FREQ_BASE),
bb, return_block, NULL);
+ reset_debug_bindings (id, stmt_gsi);
+
/* Reset the escaped solution. */
if (cfun->gimple_df)
pt_solution_reset (&cfun->gimple_df->escaped);