re PR tree-optimization/43220 (Paritially optimized __builtin_save_stack/__builtin_restore_stack causes segmentation fault)

2010-03-01  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/43220
	* tree-ssa-ccp.c (optimize_stack_restore): Do not optimize
	BUILT_IN_STACK_{SAVE,RESTORE} around alloca.

	* gcc.c-torture/execute/pr43220.c: New testcase.

From-SVN: r157149
This commit is contained in:
Richard Guenther 2010-03-01 16:57:02 +00:00 committed by Richard Biener
parent f0c10f0fab
commit 12f9ddbc7d
4 changed files with 43 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2010-03-01 Richard Guenther <rguenther@suse.de>
PR tree-optimization/43220
* tree-ssa-ccp.c (optimize_stack_restore): Do not optimize
BUILT_IN_STACK_{SAVE,RESTORE} around alloca.
2010-03-01 Richard Guenther <rguenther@suse.de>
Martin Jambor <mjambor@suse.cz>

View File

@ -1,3 +1,8 @@
2010-03-01 Richard Guenther <rguenther@suse.de>
PR tree-optimization/43220
* gcc.c-torture/execute/pr43220.c: New testcase.
2010-03-01 Richard Guenther <rguenther@suse.de>
PR middle-end/43213

View File

@ -0,0 +1,28 @@
void *volatile p;
int
main (void)
{
int n = 0;
lab:;
{
int x[n % 1000 + 1];
x[0] = 1;
x[n % 1000] = 2;
p = x;
n++;
}
{
int x[n % 1000 + 1];
x[0] = 1;
x[n % 1000] = 2;
p = x;
n++;
}
if (n < 1000000)
goto lab;
return 0;
}

View File

@ -3203,7 +3203,10 @@ optimize_stack_restore (gimple_stmt_iterator i)
continue;
callee = gimple_call_fndecl (stmt);
if (!callee || DECL_BUILT_IN_CLASS (callee) != BUILT_IN_NORMAL)
if (!callee
|| DECL_BUILT_IN_CLASS (callee) != BUILT_IN_NORMAL
/* All regular builtins are ok, just obviously not alloca. */
|| DECL_FUNCTION_CODE (callee) == BUILT_IN_ALLOCA)
return NULL_TREE;
if (DECL_FUNCTION_CODE (callee) == BUILT_IN_STACK_RESTORE)