pr23382.c: Avoid DCE from eliminating dead variable.

* gcc.dg/tree-ssa/pr23382.c: Avoid DCE from eliminating dead variable.
	* tree-ssa-dce.c (eliminate_unnecesary_stmts): Remove dead LHS of calls.

From-SVN: r121108
This commit is contained in:
Jan Hubicka 2007-01-24 13:13:45 +01:00 committed by Jan Hubicka
parent 024a85aeb6
commit cf22730346
4 changed files with 36 additions and 2 deletions

View File

@ -1,3 +1,7 @@
2007-01-24 Jan Hubicka <jh@suse.cz>
* tree-ssa-dce.c (eliminate_unnecesary_stmts): Remove dead LHS of calls.
2007-01-24 Andreas Krebbel <krebbel1@de.ibm.com>
* c-cppbuiltin.c (builtin_define_type_sizeof): New function.

View File

@ -1,3 +1,7 @@
2007-01-24 Jan Hubicka <jh@suse.cz>
* gcc.dg/tree-ssa/pr23382.c: Avoid DCE from eliminating dead variable.
2007-01-24 Andreas Krebbel <krebbel1@de.ibm.com>
* gcc.c-torture/compile/sizeof-macros-1.c: New testcase.

View File

@ -8,9 +8,10 @@ struct a
void *malloc(__SIZE_TYPE__ size) __attribute__((malloc));
void f(void)
int f(void)
{
struct a *a = malloc(sizeof(struct a));
return a.length;
}
/* { dg-final { scan-tree-dump-times "VDEF <HEAP" 1 "alias1"} } */
/* { dg-final { scan-tree-dump-times "VDEF <HEAP" 1 "alias2"} } */

View File

@ -688,7 +688,32 @@ eliminate_unnecessary_stmts (void)
{
tree call = get_call_expr_in (t);
if (call)
notice_special_calls (call);
{
tree name;
/* When LHS of var = call (); is dead, simplify it into
call (); saving one operand. */
if (TREE_CODE (t) == GIMPLE_MODIFY_STMT
&& (TREE_CODE ((name = GIMPLE_STMT_OPERAND (t, 0)))
== SSA_NAME)
&& !TEST_BIT (processed, SSA_NAME_VERSION (name)))
{
something_changed = true;
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Deleting LHS of call: ");
print_generic_stmt (dump_file, t, TDF_SLIM);
fprintf (dump_file, "\n");
}
push_stmt_changes (bsi_stmt_ptr (i));
TREE_BLOCK (call) = TREE_BLOCK (t);
bsi_replace (&i, call, false);
maybe_clean_or_replace_eh_stmt (t, call);
mark_symbols_for_renaming (call);
pop_stmt_changes (bsi_stmt_ptr (i));
}
notice_special_calls (call);
}
bsi_next (&i);
}
}