asan.c (instrument_derefs): Disable instrumentation on asan-globals=0.
authorMarat Zakirov <m.zakirov@samsung.com>
Wed, 11 Mar 2015 07:39:20 +0000 (07:39 +0000)
committerMarat Zakirov <mzakirov@gcc.gnu.org>
Wed, 11 Mar 2015 07:39:20 +0000 (07:39 +0000)
2015-03-11  Marat Zakirov  <m.zakirov@samsung.com>

* asan.c (instrument_derefs): Disable instrumentation on asan-globals=0.
* c-c++-common/asan/no-asan-check-glob.c: New test.

From-SVN: r221345

gcc/ChangeLog
gcc/asan.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/asan/no-asan-check-glob.c [new file with mode: 0644]

index b77fb5e99d0f5e1d61e836c3c21c9ed41e8b30be..4a7f788147278a11fd440bfa89fba52b703cc564 100644 (file)
@@ -1,3 +1,7 @@
+2015-03-11  Marat Zakirov  <m.zakirov@samsung.com>
+
+       * asan.c (instrument_derefs): Disable instrumentation on asan-globals=0.
+
 2015-03-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/65368
index b7c2b11ed5479f1edd9b663e0e8ea3817f052df1..9e4a62998179c1dca00a47f790e41ddcc6355027 100644 (file)
@@ -1820,6 +1820,8 @@ instrument_derefs (gimple_stmt_iterator *iter, tree t,
     {
       if (DECL_THREAD_LOCAL_P (inner))
        return;
+      if (!ASAN_GLOBALS && is_global_var (inner))
+        return;
       if (!TREE_STATIC (inner))
        {
          /* Automatic vars in the current function will be always
index a45346aaf188667906439a9dcd2c9c19b4c49c22..7253a53b239e61952ba17b85c331a9f9975cb128 100644 (file)
@@ -1,3 +1,7 @@
+2015-03-11  Marat Zakirov  <m.zakirov@samsung.com>
+
+       * c-c++-common/asan/no-asan-check-glob.c: New test.
+
 2015-03-10  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/65370
diff --git a/gcc/testsuite/c-c++-common/asan/no-asan-check-glob.c b/gcc/testsuite/c-c++-common/asan/no-asan-check-glob.c
new file mode 100644 (file)
index 0000000..a1b1410
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-options "--param asan-globals=0 -fdump-tree-asan" } */
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "-O0" } { "*" } } */
+
+extern int a;
+
+int foo ()
+{
+  return a;
+}
+
+/* { dg-final { scan-tree-dump-times "ASAN_CHECK" 0 "asan1" } } */
+/* { dg-final { cleanup-tree-dump "asan1" } } */