On 06/08/2011 11:42 AM, Tom de Vries wrote:
> I'll send the patch with the testcases in a separate email.
OK for trunk?
Thanks,
- Tom
2011-06-08 Tom de Vries <[email protected]>
PR middle-end/43864
* gcc.dg/pr43864.c: New test.
* gcc.dg/pr43864-2.c: New test.
Index: gcc/testsuite/gcc.dg/pr43864-2.c
===================================================================
--- /dev/null (new file)
+++ gcc/testsuite/gcc.dg/pr43864-2.c (revision 0)
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+int f(int c, int b, int d)
+{
+ int r, e;
+
+ if (c)
+ r = b + d;
+ else
+ {
+ e = b + d;
+ r = e;
+ }
+
+ return r;
+}
+
+/* { dg-final { scan-tree-dump-times "if " 0 "optimized"} } */
+/* { dg-final { scan-tree-dump-times "\\\+" 1 "optimized"} } */
+/* { dg-final { scan-tree-dump-times "PHI" 0 "optimized"} } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
Index: gcc/testsuite/gcc.dg/pr43864.c
===================================================================
--- /dev/null (new file)
+++ gcc/testsuite/gcc.dg/pr43864.c (revision 0)
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+void foo (char*, FILE*);
+
+char* hprofStartupp (char *outputFileName, char *ctx)
+{
+ char fileName[1000];
+ FILE *fp;
+ sprintf (fileName, outputFileName);
+ if (access (fileName, 1) == 0)
+ {
+ free (ctx);
+ return 0;
+ }
+
+ fp = fopen (fileName, 0);
+ if (fp == 0)
+ {
+ free (ctx);
+ return 0;
+ }
+
+ foo (outputFileName, fp);
+
+ return ctx;
+}
+
+/* { dg-final { scan-tree-dump-times "free" 1 "optimized"} } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */