public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] optionally disable global check
@ 2015-03-06 14:23 Marat Zakirov
  2015-03-06 15:41 ` Yury Gribov
  2015-03-11 19:50 ` Jakub Jelinek
  0 siblings, 2 replies; 4+ messages in thread
From: Marat Zakirov @ 2015-03-06 14:23 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jakub Jelinek, Yury Gribov

[-- Attachment #1: Type: text/plain, Size: 152 bytes --]

Hi all!

Currently !ASAN_GLOBALS disables red-zones for global variables but 
keeps their checks. This simple patch disables these checks too.

--Marat

[-- Attachment #2: mavdt-208_2.diff --]
[-- Type: text/x-patch, Size: 1241 bytes --]

gcc/ChangeLog:

2015-01-22  Marat Zakirov  <m.zakirov@samsung.com>

	* asan.c (instrument_derefs): asan-globals=0 disable instrumentation.

gcc/testsuite/ChangeLog:

2015-01-22  Marat Zakirov  <m.zakirov@samsung.com>

	* c-c++-common/asan/no-asan-check-glob.c: New test.


diff --git a/gcc/asan.c b/gcc/asan.c
index be28ede..c331f67 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -1809,6 +1809,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
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
index 0000000..a1b1410
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/no-asan-check-glob.c
@@ -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" } } */

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-03-11 19:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-06 14:23 [PATCH] optionally disable global check Marat Zakirov
2015-03-06 15:41 ` Yury Gribov
2015-03-09 14:45   ` Jakub Jelinek
2015-03-11 19:50 ` Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).