[PATCH] Fix stdarg optimization (PR tree-optimization/23818)
Jakub Jelinek
jakub@redhat.com
Mon Sep 12 14:09:00 GMT 2005
Hi!
The testcase below ICEs on x86-64. The problem is that tree-stdarg.c relied
on CDI_DOMINATORS info being computed, but never made sure it actually is
computed. Fixed thusly, ok to commit?
2005-09-12 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/23818
* tree-stdarg.c (execute_optimize_stdarg): Call
calculate_dominance_info.
* gcc.dg/pr23818.c: New test.
--- gcc/tree-stdarg.c.jj 2005-09-12 15:38:14.000000000 +0200
+++ gcc/tree-stdarg.c 2005-09-12 15:53:22.000000000 +0200
@@ -734,6 +734,8 @@ execute_optimize_stdarg (void)
if (va_list_simple_ptr)
cfun->va_list_fpr_size = VA_LIST_MAX_FPR_SIZE;
+ calculate_dominance_info (CDI_DOMINATORS);
+
FOR_EACH_BB (bb)
{
block_stmt_iterator i;
--- gcc/testsuite/gcc.dg/pr23818.c.jj 2005-09-12 16:05:26.000000000 +0200
+++ gcc/testsuite/gcc.dg/pr23818.c 2005-09-12 16:03:28.000000000 +0200
@@ -0,0 +1,33 @@
+/* PR tree-optimization/23818 */
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-tree-dominator-opts" } */
+
+#include <stdarg.h>
+
+extern void abort (void);
+
+void
+foo (int p[100], int k, ...)
+{
+ int j, *q;
+ va_list ap;
+
+ va_start (ap, k);
+ q = va_arg (ap, int *);
+ for (j = 0; j < 100; j++)
+ q[j] = p[j] + 10;
+ va_end(ap);
+}
+
+int
+main (void)
+{
+ int buf[100], buf2[100], i;
+ for (i = 0; i < 100; i++)
+ buf[i] = i + 1;
+ foo (buf, 0, buf2);
+ for (i = 0; i < 100; i++)
+ if (buf2[i] != buf[i] + 10)
+ abort ();
+ return 0;
+}
Jakub
More information about the Gcc-patches
mailing list