re PR tree-optimization/92056 (ice in expr_object_size, at tree-object-si ze.c:675...
authorJakub Jelinek <jakub@redhat.com>
Thu, 17 Oct 2019 07:21:24 +0000 (09:21 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 17 Oct 2019 07:21:24 +0000 (09:21 +0200)
PR tree-optimization/92056
* tree-object-size.c (cond_expr_object_size): Return early if then_
processing resulted in unknown size.

* gcc.c-torture/compile/pr92056.c: New test.

From-SVN: r277093

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr92056.c [new file with mode: 0644]
gcc/tree-object-size.c

index 5fccbd4..0dd5d8c 100644 (file)
@@ -1,5 +1,9 @@
 2019-10-17  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/92056
+       * tree-object-size.c (cond_expr_object_size): Return early if then_
+       processing resulted in unknown size.
+
        PR tree-optimization/92115
        * tree-ssa-ifcombine.c (ifcombine_ifandif): Force condition into
        temporary if it could trap.
index c79ba7b..eb3112d 100644 (file)
@@ -1,5 +1,8 @@
 2019-10-17  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/92056
+       * gcc.c-torture/compile/pr92056.c: New test.
+
        PR tree-optimization/92115
        * gcc.dg/pr92115.c: New test.
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr92056.c b/gcc/testsuite/gcc.c-torture/compile/pr92056.c
new file mode 100644 (file)
index 0000000..d04da76
--- /dev/null
@@ -0,0 +1,18 @@
+/* PR tree-optimization/92056 */
+
+const char *d;
+
+void
+foo (int c, char *e, const char *a, const char *b)
+{
+  switch (c)
+    {
+    case 33:
+      for (;; d++)
+        if (__builtin_strcmp (b ? : "", d))
+          return;
+      break;
+    case 4:
+      __builtin_sprintf (e, a);
+    }
+}
index db9b569..6e79bbd 100644 (file)
@@ -903,6 +903,9 @@ cond_expr_object_size (struct object_size_info *osi, tree var, gimple *stmt)
   else
     expr_object_size (osi, var, then_);
 
+  if (object_sizes[object_size_type][varno] == unknown[object_size_type])
+    return reexamine;
+
   if (TREE_CODE (else_) == SSA_NAME)
     reexamine |= merge_object_sizes (osi, var, else_, 0);
   else