re PR sanitizer/64170 (ICE compiling Linux Kernel drivers/media/rc/imon.c in imon_inc...
authorJakub Jelinek <jakub@redhat.com>
Fri, 5 Dec 2014 23:00:09 +0000 (00:00 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 5 Dec 2014 23:00:09 +0000 (00:00 +0100)
PR sanitizer/64170
* sanopt.c (maybe_optimize_asan_check_ifn): If base_checks is
non-NULL, call maybe_get_dominating_check on it even if g is
non-NULL.

* gcc.dg/asan/pr64170.c: New test.

From-SVN: r218440

gcc/ChangeLog
gcc/sanopt.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/asan/pr64170.c [new file with mode: 0644]

index 0dcf6498e320f28df3242d0f38c7efd206971921..f9fba3e6ce10d59609881f3315425afcbe63a891 100644 (file)
@@ -1,3 +1,10 @@
+2014-12-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/64170
+       * sanopt.c (maybe_optimize_asan_check_ifn): If base_checks is
+       non-NULL, call maybe_get_dominating_check on it even if g is
+       non-NULL.
+
 2014-12-05  Jeff Law  <law@redhat.com>
 
        * doc/md.texi: Note problems using function calls to determine
index e0d3a8562b37b9ca3f5ea5980342520167f6d908..ce9fbcf604a8dbd3be0968316ccae9cc5daa5fcd 100644 (file)
@@ -408,12 +408,13 @@ maybe_optimize_asan_check_ifn (struct sanopt_ctx *ctx, gimple stmt)
     }
 
   gimple g = maybe_get_dominating_check (*ptr_checks);
+  gimple g2 = NULL;
 
-  if (!g && base_checks)
+  if (base_checks)
     /* Try with base address as well.  */
-    g = maybe_get_dominating_check (*base_checks);
+    g2 = maybe_get_dominating_check (*base_checks);
 
-  if (!g)
+  if (g == NULL && g2 == NULL)
     {
       /* For this PTR we don't have any ASAN_CHECK stmts recorded, so there's
         nothing to optimize yet.  */
index dcef9d2c3d68aa8898ea70dd49c2e428b3768cd3..b52905e34f8ef115240e86faa82898be3f5f9f25 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/64170
+       * gcc.dg/asan/pr64170.c: New test.
+
 2014-12-05  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        PR target/53199
diff --git a/gcc/testsuite/gcc.dg/asan/pr64170.c b/gcc/testsuite/gcc.dg/asan/pr64170.c
new file mode 100644 (file)
index 0000000..c4edcaa
--- /dev/null
@@ -0,0 +1,17 @@
+/* PR sanitizer/64170 */
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=address,null" } */
+
+int a, *b, c;
+void bar (int);
+
+void
+foo (void)
+{
+  char *d = (char *) b;
+  if (d[0] && d[1])
+    return;
+  if (c)
+    a = *(int *) d;
+  bar (*(int *) d);
+}