objsz: Don't call replace_uses_by on SSA_NAME_OCCURS_IN_ABNORMAL_PHI [PR94423]
authorJakub Jelinek <jakub@redhat.com>
Wed, 1 Apr 2020 07:44:59 +0000 (09:44 +0200)
committerJakub Jelinek <jakub@redhat.com>
Wed, 1 Apr 2020 07:44:59 +0000 (09:44 +0200)
The following testcase ICEs because the objsz pass calls replace_uses_by
on SSA_NAME_OCCURS_IN_ABNORMAL_PHI SSA_NAME.  The following patch instead
of that calls replace_call_with_value, which will turn it into
  xyz_123(ab) = 234;

2020-04-01  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/94423
* tree-object-size.c (pass_object_sizes::execute): Don't call
replace_uses_by for SSA_NAME_OCCURS_IN_ABNORMAL_PHI lhs, instead
call replace_call_with_value.

* gcc.dg/ubsan/pr94423.c: New test.

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/ubsan/pr94423.c [new file with mode: 0644]
gcc/tree-object-size.c

index fc836b83e171944bbb9e8a788113149db5ea2999..654356c8dc8f08fb53e0e9b5c39e756e68326193 100644 (file)
@@ -1,3 +1,10 @@
+2020-04-01  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/94423
+       * tree-object-size.c (pass_object_sizes::execute): Don't call
+       replace_uses_by for SSA_NAME_OCCURS_IN_ABNORMAL_PHI lhs, instead
+       call replace_call_with_value.
+
 2020-04-01  Kewen Lin  <linkw@gcc.gnu.org>
 
        PR tree-optimization/94043
index 6f41ffbb048735e555b907b8b78ab4cd160a1d85..49a45f2854e78c2f5d320ba547b52ec015830cd4 100644 (file)
@@ -1,3 +1,8 @@
+2020-04-01  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/94423
+       * gcc.dg/ubsan/pr94423.c: New test.
+
 2020-04-01  Kewen Lin  <linkw@gcc.gnu.org>
 
        PR tree-optimization/94043
diff --git a/gcc/testsuite/gcc.dg/ubsan/pr94423.c b/gcc/testsuite/gcc.dg/ubsan/pr94423.c
new file mode 100644 (file)
index 0000000..76f831f
--- /dev/null
@@ -0,0 +1,17 @@
+/* PR middle-end/94423 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fsanitize=object-size" } */
+
+void foo (void);
+typedef struct { long buf[22]; } jmp_buf[1];
+extern int sigsetjmp (jmp_buf, int) __attribute__ ((__nothrow__));
+jmp_buf buf;
+
+void
+bar (int *c)
+{
+  while (*c)
+    foo ();
+  while (*c)
+    sigsetjmp (buf, 0);
+}
index 116413c2d8f611c9bee3757e6900e8eb0591a4df..255ea63cab6d5cf8ef68cfa6e3adb18b8c41849c 100644 (file)
@@ -1393,7 +1393,10 @@ pass_object_sizes::execute (function *fun)
            }
 
          /* Propagate into all uses and fold those stmts.  */
-         replace_uses_by (lhs, result);
+         if (!SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs))
+           replace_uses_by (lhs, result);
+         else
+           replace_call_with_value (&i, result);
        }
     }