]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR middle-end/37669
authornemet <nemet@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 21 Oct 2008 17:46:53 +0000 (17:46 +0000)
committernemet <nemet@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 21 Oct 2008 17:46:53 +0000 (17:46 +0000)
* tree-ssa-ccp.c (ccp_fold_builtin): Only allow one argument to be
processed by get_maxval_strlen.

testsuite/
PR middle-end/37669
* gcc.c-torture/compile/pr37669-2.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141270 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr37669-2.c [new file with mode: 0644]
gcc/tree-ssa-ccp.c

index 455fcd947433ca4804a968daebd20c8055a36086..2400d9966b936edb8458ee587b9d697a33b8344e 100644 (file)
@@ -1,3 +1,9 @@
+2008-10-21  Adam Nemet  <anemet@caviumnetworks.com>
+
+       PR middle-end/37669
+       * tree-ssa-ccp.c (ccp_fold_builtin): Only allow one argument to be
+       processed by get_maxval_strlen.
+
 2008-10-21  David Edelsohn  <edelsohn@gnu.org>
 
        PR target/35485
index e65e7253fac94d3080ed6a9ae3b3a610a192c127..ddabb98422397ec6b402f6a8617ac46075905927 100644 (file)
@@ -1,3 +1,8 @@
+2008-10-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/37669
+       * gcc.c-torture/compile/pr37669-2.c: New test.
+
 2008-10-21  Richard Guenther  <rguenther@suse.de>
 
        * gcc.dg/tree-ssa/alias-19.c: New testcase.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr37669-2.c b/gcc/testsuite/gcc.c-torture/compile/pr37669-2.c
new file mode 100644 (file)
index 0000000..abeae7a
--- /dev/null
@@ -0,0 +1,14 @@
+/* PR middle-end/37669 */
+
+#define FMT10 "%d%d%d%d%d%d%d%d%d%d"
+#define FMT100 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10
+#define FMT1000 FMT100 FMT100 FMT100 FMT100 FMT100 \
+               FMT100 FMT100 FMT100 FMT100 FMT100
+#define ARG10 , i, i, i, i, i, i, i, i, i, i
+#define ARG100 ARG10 ARG10 ARG10 ARG10 ARG10 ARG10 ARG10 ARG10 ARG10 ARG10
+#define ARG1000 ARG100 ARG100 ARG100 ARG100 ARG100 \
+               ARG100 ARG100 ARG100 ARG100 ARG100
+void foo (char *s, int i, int j)
+{
+  __builtin___snprintf_chk (s, i, 1, j, FMT1000 ARG1000);
+}
index 383367e9fb1c1bd761c79002b2c7aab6f2083263..0365697fc85e4d2dd596f5b65132666d91db7353 100644 (file)
@@ -2430,7 +2430,7 @@ ccp_fold_builtin (gimple stmt)
 {
   tree result, val[3];
   tree callee, a;
-  int arg_mask, i, type;
+  int arg_idx, type;
   bitmap visited;
   bool ignore;
   int nargs;
@@ -2466,12 +2466,12 @@ ccp_fold_builtin (gimple stmt)
     case BUILT_IN_STRLEN:
     case BUILT_IN_FPUTS:
     case BUILT_IN_FPUTS_UNLOCKED:
-      arg_mask = 1;
+      arg_idx = 0;
       type = 0;
       break;
     case BUILT_IN_STRCPY:
     case BUILT_IN_STRNCPY:
-      arg_mask = 2;
+      arg_idx = 1;
       type = 0;
       break;
     case BUILT_IN_MEMCPY_CHK:
@@ -2479,17 +2479,17 @@ ccp_fold_builtin (gimple stmt)
     case BUILT_IN_MEMMOVE_CHK:
     case BUILT_IN_MEMSET_CHK:
     case BUILT_IN_STRNCPY_CHK:
-      arg_mask = 4;
+      arg_idx = 2;
       type = 2;
       break;
     case BUILT_IN_STRCPY_CHK:
     case BUILT_IN_STPCPY_CHK:
-      arg_mask = 2;
+      arg_idx = 1;
       type = 1;
       break;
     case BUILT_IN_SNPRINTF_CHK:
     case BUILT_IN_VSNPRINTF_CHK:
-      arg_mask = 2;
+      arg_idx = 1;
       type = 2;
       break;
     default:
@@ -2498,18 +2498,12 @@ ccp_fold_builtin (gimple stmt)
 
   /* Try to use the dataflow information gathered by the CCP process.  */
   visited = BITMAP_ALLOC (NULL);
+  bitmap_clear (visited);
 
   memset (val, 0, sizeof (val));
-  for (i = 0; i < nargs; i++)
-    {
-      if ((arg_mask >> i) & 1)
-        {
-          a = gimple_call_arg (stmt, i);
-          bitmap_clear (visited);
-          if (!get_maxval_strlen (a, &val[i], visited, type))
-            val[i] = NULL_TREE;
-        }
-    }
+  a = gimple_call_arg (stmt, arg_idx);
+  if (!get_maxval_strlen (a, &val[arg_idx], visited, type))
+    val[arg_idx] = NULL_TREE;
 
   BITMAP_FREE (visited);