* builtins.c (fold_builtin_1): Delete free (0).
* gcc.dg/tree-ssa/builtin-free.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158923
138bc75d-0d04-0410-961f-
82ee72b054a4
+2010-04-30 Richard Guenther <rguenther@suse.de>
+
+ * builtins.c (fold_builtin_1): Delete free (0).
+
2010-04-29 Jan HUbicka <jh@suse.cz>
* gengtype.c (open_base_files): Add lto-streamer.h
enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
switch (fcode)
{
-
case BUILT_IN_CONSTANT_P:
{
tree val = fold_builtin_constant_p (arg0);
case BUILT_IN_VPRINTF:
return fold_builtin_printf (loc, fndecl, arg0, NULL_TREE, ignore, fcode);
+ case BUILT_IN_FREE:
+ if (integer_zerop (arg0))
+ return build_empty_stmt (loc);
+ break;
+
default:
break;
}
+2010-04-30 Richard Guenther <rguenther@suse.de>
+
+ * gcc.dg/tree-ssa/builtin-free.c: New testcase.
+
2010-04-29 Fabien ChĂȘne <fabien.chene@gmail.com>
PR c++/43890
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+void bar (void *);
+void foo(unsigned n)
+{
+ void *p = __builtin_malloc (n);
+ if (p)
+ {
+ bar (p);
+ __builtin_free (p);
+ p = 0;
+ }
+ __builtin_free (p);
+}
+
+/* We should remove the redundant call to free. */
+
+/* { dg-final { scan-tree-dump-times "free" 1 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */