aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-01-18 20:30:33 +0000
committerJakub Jelinek <jakub@redhat.com>2018-01-18 20:30:33 +0000
commite438f84959f77b79a61cdefa852a5f8041dfb03c (patch)
treed3b25d4d5a26001425b9b68638df47855a0c1354
parent455fa1cac348144ea324a221f8984c4ea67449d4 (diff)
PR sanitizer/81715
PR testsuite/83882 * function.h (gimplify_parameters): Add gimple_seq * argument. * function.c: Include gimple.h and options.h. (gimplify_parameters): Add cleanup argument, add CLOBBER stmts for the added local temporaries if needed. * gimplify.c (gimplify_body): Adjust gimplify_parameters caller, if there are any parameter cleanups, wrap whole body into a try/finally with the cleanups. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@256861 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/function.c14
-rw-r--r--gcc/function.h2
-rw-r--r--gcc/gimplify.c11
4 files changed, 35 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1341714cc95..4a52a308e10 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,15 @@
+2018-01-18 Jakub Jelinek <jakub@redhat.com>
+
+ PR sanitizer/81715
+ PR testsuite/83882
+ * function.h (gimplify_parameters): Add gimple_seq * argument.
+ * function.c: Include gimple.h and options.h.
+ (gimplify_parameters): Add cleanup argument, add CLOBBER stmts
+ for the added local temporaries if needed.
+ * gimplify.c (gimplify_body): Adjust gimplify_parameters caller,
+ if there are any parameter cleanups, wrap whole body into a
+ try/finally with the cleanups.
+
2018-01-18 Wilco Dijkstra <wdijkstr@arm.com>
PR target/82964
diff --git a/gcc/function.c b/gcc/function.c
index d1d2edb2f1f..1a09ff0d31e 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -79,6 +79,8 @@ along with GCC; see the file COPYING3. If not see
#include "tree-ssa.h"
#include "stringpool.h"
#include "attribs.h"
+#include "gimple.h"
+#include "options.h"
/* So we can assign to cfun in this file. */
#undef cfun
@@ -3993,7 +3995,7 @@ gimplify_parm_type (tree *tp, int *walk_subtrees, void *data)
statements to add to the beginning of the function. */
gimple_seq
-gimplify_parameters (void)
+gimplify_parameters (gimple_seq *cleanup)
{
struct assign_parm_data_all all;
tree parm;
@@ -4058,6 +4060,16 @@ gimplify_parameters (void)
else if (TREE_CODE (type) == COMPLEX_TYPE
|| TREE_CODE (type) == VECTOR_TYPE)
DECL_GIMPLE_REG_P (local) = 1;
+
+ if (!is_gimple_reg (local)
+ && flag_stack_reuse != SR_NONE)
+ {
+ tree clobber = build_constructor (type, NULL);
+ gimple *clobber_stmt;
+ TREE_THIS_VOLATILE (clobber) = 1;
+ clobber_stmt = gimple_build_assign (local, clobber);
+ gimple_seq_add_stmt (cleanup, clobber_stmt);
+ }
}
else
{
diff --git a/gcc/function.h b/gcc/function.h
index 642e63b7510..7e59050e8a6 100644
--- a/gcc/function.h
+++ b/gcc/function.h
@@ -607,7 +607,7 @@ extern bool initial_value_entry (int i, rtx *, rtx *);
extern void instantiate_decl_rtl (rtx x);
extern int aggregate_value_p (const_tree, const_tree);
extern bool use_register_for_decl (const_tree);
-extern gimple_seq gimplify_parameters (void);
+extern gimple_seq gimplify_parameters (gimple_seq *);
extern void locate_and_pad_parm (machine_mode, tree, int, int, int,
tree, struct args_size *,
struct locate_and_pad_arg_data *);
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 8e86c338fc1..7fedd973c88 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -12589,7 +12589,7 @@ gbind *
gimplify_body (tree fndecl, bool do_parms)
{
location_t saved_location = input_location;
- gimple_seq parm_stmts, seq;
+ gimple_seq parm_stmts, parm_cleanup = NULL, seq;
gimple *outer_stmt;
gbind *outer_bind;
struct cgraph_node *cgn;
@@ -12628,7 +12628,7 @@ gimplify_body (tree fndecl, bool do_parms)
/* Resolve callee-copies. This has to be done before processing
the body so that DECL_VALUE_EXPR gets processed correctly. */
- parm_stmts = do_parms ? gimplify_parameters () : NULL;
+ parm_stmts = do_parms ? gimplify_parameters (&parm_cleanup) : NULL;
/* Gimplify the function's body. */
seq = NULL;
@@ -12657,6 +12657,13 @@ gimplify_body (tree fndecl, bool do_parms)
tree parm;
gimplify_seq_add_seq (&parm_stmts, gimple_bind_body (outer_bind));
+ if (parm_cleanup)
+ {
+ gtry *g = gimple_build_try (parm_stmts, parm_cleanup,
+ GIMPLE_TRY_FINALLY);
+ parm_stmts = NULL;
+ gimple_seq_add_stmt (&parm_stmts, g);
+ }
gimple_bind_set_body (outer_bind, parm_stmts);
for (parm = DECL_ARGUMENTS (current_function_decl);