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 5fccbd4d1d8802f2c263214e531969baedd1ccc3..0dd5d8ca839bb6fb64e825bf74bfa5640c03ee7d 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 c79ba7b989a168ffe53cd4b01fa25d0b463e7fc6..eb3112d2672b4cf60d160a9b7bc5b62961568d9e 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 db9b5694e85d2afce4df21e730823efd3dfc5f7e..6e79bbd1d917fe8e49869ad4a939e9cfb4578b86 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