Commit 6aee2fd0 by Jakub Jelinek Committed by Jakub Jelinek

re PR sanitizer/81715 (asan-stack=1 redzone allocation is too inflexible)

	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.

From-SVN: r256861
parent d3a9902e
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
......
......@@ -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
{
......
......@@ -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 *);
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment