]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/64121 (ICE: SSA corruption with -O -fsanitize=undefined)
authorMarek Polacek <polacek@redhat.com>
Mon, 1 Dec 2014 15:37:55 +0000 (15:37 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 1 Dec 2014 15:37:55 +0000 (15:37 +0000)
PR sanitizer/64121
* ubsan.c (instrument_object_size): Stop searching if the base
occurs in abnormal phi.

* c-c++-common/ubsan/pr64121.c: New test.

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r218222

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/ubsan/pr64121.c [new file with mode: 0644]
gcc/ubsan.c

index f75ecf5391e2f74ed1f5aacd9d2218acc144cec3..08f40967ca83f1ca3119cb57414cde8c4db793f5 100644 (file)
@@ -1,3 +1,10 @@
+2014-12-01  Marek Polacek  <polacek@redhat.com>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/64121
+       * ubsan.c (instrument_object_size): Stop searching if the base
+       occurs in abnormal phi.
+
 2014-12-01  Marek Polacek  <polacek@redhat.com>
 
        PR sanitizer/63956
index d7635f2f21a42eb9c946818a2164343b0df79992..3be4a88fa5792343dcb456f3a6f567a7cd3a3bac 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-01  Marek Polacek  <polacek@redhat.com>
+
+       PR sanitizer/64121
+       * c-c++-common/ubsan/pr64121.c: New test.
+
 2014-12-01  Marek Polacek  <polacek@redhat.com>
 
        PR sanitizer/63956
diff --git a/gcc/testsuite/c-c++-common/ubsan/pr64121.c b/gcc/testsuite/c-c++-common/ubsan/pr64121.c
new file mode 100644 (file)
index 0000000..614d72a
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR sanitizer/64121 */
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=undefined -Wno-pointer-arith" } */
+
+extern int tab[16];
+
+void
+execute (int *ip, int x)
+{
+  int *xp = tab;
+base:
+  if (x)
+    return;
+  *xp++ = *ip;
+  goto *(&&base + *ip);
+}
index cff0982eac7eb200c10c83c2246ee9bdfa75c80f..fb5f104d7019a7f1d930036888aa294d037e4936 100644 (file)
@@ -1563,7 +1563,14 @@ instrument_object_size (gimple_stmt_iterator *gsi, bool is_lhs)
              && POINTER_TYPE_P (TREE_TYPE (gimple_assign_rhs1 (def_stmt))))
          || (is_gimple_assign (def_stmt)
              && gimple_assign_rhs_code (def_stmt) == POINTER_PLUS_EXPR))
-       base = gimple_assign_rhs1 (def_stmt);
+       {
+         tree rhs1 = gimple_assign_rhs1 (def_stmt);
+         if (TREE_CODE (rhs1) == SSA_NAME
+           && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs1))
+           break;
+         else
+           base = rhs1;
+       }
       else
        break;
     }