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 22:21:12 +0000 (00:21 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 17 Oct 2019 22:21:12 +0000 (00:21 +0200)
PR tree-optimization/92056
* tree-ssa-strlen.c (determine_min_objsize): Call init_object_sizes
before calling compute_builtin_object_size.

* gcc.dg/tree-ssa/pr92056.c: New test.

From-SVN: r277134

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr92056.c [new file with mode: 0644]
gcc/tree-ssa-strlen.c

index ebb7cbcbda96b15b7ac5948c77d582d453f270a3..c137c56fb6144af0c9893d90afd971764d423850 100644 (file)
@@ -1,3 +1,9 @@
+2019-10-18  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/92056
+       * tree-ssa-strlen.c (determine_min_objsize): Call init_object_sizes
+       before calling compute_builtin_object_size.
+
 2019-10-17  Iain Sandoe  <iain@sandoe.co.uk>
 
        PR target/65342
index 93f15a54705b755791e1692285c009876cd6281d..2d2a2748249f82cdf47598c1f78a85d0e4aabddf 100644 (file)
@@ -1,3 +1,8 @@
+2019-10-18  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/92056
+       * gcc.dg/tree-ssa/pr92056.c: New test.
+
 2019-10-17  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * g++.old-deja/g++.other/decl9.C: Check locations too.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr92056.c b/gcc/testsuite/gcc.dg/tree-ssa/pr92056.c
new file mode 100644 (file)
index 0000000..e43d0c0
--- /dev/null
@@ -0,0 +1,36 @@
+/* PR tree-optimization/92056 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-final { scan-tree-dump-times "return 1;" 2 "optimized" } } */
+/* { dg-final { scan-tree-dump-not "strcmp \\(" "optimized" } } */
+
+void bar (int, char *);
+
+int
+foo (int x, char *y, const char *z)
+{
+  char *a;
+  __builtin_sprintf (y, z);
+  if (x == 3)
+    a = __builtin_malloc (5);
+  else if (x == 7)
+    a = __builtin_malloc (6);
+  else
+    a = __builtin_malloc (7);
+  bar (x, a);
+  return __builtin_strcmp (a, "abcdefg") != 0;
+}
+
+int
+baz (int x)
+{
+  char *a;
+  if (x == 3)
+    a = __builtin_malloc (5);
+  else if (x == 7)
+    a = __builtin_malloc (6);
+  else
+    a = __builtin_malloc (7);
+  bar (x, a);
+  return __builtin_strcmp (a, "abcdefg") != 0;
+}
index 5c229ca73109ff77ee7c0d81a7d730a483421e5b..d5833f69766f71cf8eac981d2490b6842ba1de10 100644 (file)
@@ -3462,6 +3462,8 @@ determine_min_objsize (tree dest)
 {
   unsigned HOST_WIDE_INT size = 0;
 
+  init_object_sizes ();
+
   if (compute_builtin_object_size (dest, 2, &size))
     return size;