Commit c54e2022 by Richard Biener Committed by Richard Biener

re PR middle-end/59330 (Crash in is_gimple_reg_type)

2013-11-28  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/59330
	* tree-ssa-dce.c (eliminate_unnecessary_stmts): Simplify
	and fix delayed marking of free calls not necessary.

	* gcc.dg/torture/pr59330.c: New testcase.

From-SVN: r205486
parent 0c6b087c
2013-11-28 Richard Biener <rguenther@suse.de>
PR tree-optimization/59330
* tree-ssa-dce.c (eliminate_unnecessary_stmts): Simplify
and fix delayed marking of free calls not necessary.
2013-11-28 Andrew MacLeod <amacleod@redhat.com> 2013-11-28 Andrew MacLeod <amacleod@redhat.com>
* tree-ssa-propagate.c (valid_gimple_call_p): Pass TREE_TYPE to * tree-ssa-propagate.c (valid_gimple_call_p): Pass TREE_TYPE to
2013-11-28 Richard Biener <rguenther@suse.de> 2013-11-28 Richard Biener <rguenther@suse.de>
PR tree-optimization/59330
* gcc.dg/torture/pr59330.c: New testcase.
2013-11-28 Richard Biener <rguenther@suse.de>
PR lto/59323 PR lto/59323
* gcc.dg/lto/pr59323_0.c: New testcase. * gcc.dg/lto/pr59323_0.c: New testcase.
......
/* { dg-do run } */
void free(void *ptr)
{
}
void *foo(void)
{
return 0;
}
int main(void)
{
void *p = foo();
free(p);
return 0;
}
...@@ -1191,26 +1191,18 @@ eliminate_unnecessary_stmts (void) ...@@ -1191,26 +1191,18 @@ eliminate_unnecessary_stmts (void)
stats.total++; stats.total++;
/* We can mark a call to free as not necessary if the /* We can mark a call to free as not necessary if the
defining statement of its argument is an allocation defining statement of its argument is not necessary
function and that is not necessary itself. */ (and thus is getting removed). */
if (gimple_call_builtin_p (stmt, BUILT_IN_FREE)) if (gimple_plf (stmt, STMT_NECESSARY)
&& gimple_call_builtin_p (stmt, BUILT_IN_FREE))
{ {
tree ptr = gimple_call_arg (stmt, 0); tree ptr = gimple_call_arg (stmt, 0);
tree callee2; if (TREE_CODE (ptr) == SSA_NAME)
gimple def_stmt; {
if (TREE_CODE (ptr) != SSA_NAME) gimple def_stmt = SSA_NAME_DEF_STMT (ptr);
continue; if (!gimple_plf (def_stmt, STMT_NECESSARY))
def_stmt = SSA_NAME_DEF_STMT (ptr); gimple_set_plf (stmt, STMT_NECESSARY, false);
if (!is_gimple_call (def_stmt) }
|| gimple_plf (def_stmt, STMT_NECESSARY))
continue;
callee2 = gimple_call_fndecl (def_stmt);
if (callee2 == NULL_TREE
|| DECL_BUILT_IN_CLASS (callee2) != BUILT_IN_NORMAL
|| (DECL_FUNCTION_CODE (callee2) != BUILT_IN_MALLOC
&& DECL_FUNCTION_CODE (callee2) != BUILT_IN_CALLOC))
continue;
gimple_set_plf (stmt, STMT_NECESSARY, false);
} }
/* If GSI is not necessary then remove it. */ /* If GSI is not necessary then remove it. */
......
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