diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-11-28 14:52:44 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-11-28 14:52:44 +0000 |
commit | 9af9fab58e550acd6b21d9ff72743e94469d899d (patch) | |
tree | fe2cf62fefd5928cc0053b5fa535f210ed4cbd19 /gcc/tree-ssa-dce.c | |
parent | b7b667b4b2033265b7459e4a5b03f122ca0763d7 (diff) | |
download | gcc-9af9fab58e550acd6b21d9ff72743e94469d899d.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205486 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-dce.c')
-rw-r--r-- | gcc/tree-ssa-dce.c | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index 61c5af62ced..e2177fed99c 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -1191,26 +1191,18 @@ eliminate_unnecessary_stmts (void) stats.total++; /* We can mark a call to free as not necessary if the - defining statement of its argument is an allocation - function and that is not necessary itself. */ - if (gimple_call_builtin_p (stmt, BUILT_IN_FREE)) + defining statement of its argument is not necessary + (and thus is getting removed). */ + if (gimple_plf (stmt, STMT_NECESSARY) + && gimple_call_builtin_p (stmt, BUILT_IN_FREE)) { tree ptr = gimple_call_arg (stmt, 0); - tree callee2; - gimple def_stmt; - if (TREE_CODE (ptr) != SSA_NAME) - continue; - def_stmt = SSA_NAME_DEF_STMT (ptr); - 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 (TREE_CODE (ptr) == SSA_NAME) + { + gimple def_stmt = SSA_NAME_DEF_STMT (ptr); + if (!gimple_plf (def_stmt, STMT_NECESSARY)) + gimple_set_plf (stmt, STMT_NECESSARY, false); + } } /* If GSI is not necessary then remove it. */ |