+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.
+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.
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"} } */
{
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);
}
}