opts.c (finish_options): Disable aggressive opts for sanitizer.
authorMarat Zakirov <m.zakirov@samsung.com>
Tue, 18 Nov 2014 08:46:39 +0000 (08:46 +0000)
committerMarat Zakirov <mzakirov@gcc.gnu.org>
Tue, 18 Nov 2014 08:46:39 +0000 (08:46 +0000)
gcc

2014-11-18  Marat Zakirov  <m.zakirov@samsung.com>

* opts.c (finish_options): Disable aggressive opts for sanitizer.
(common_handle_option): Move code to finish_options.

gcc/testsuite

2014-11-18  Marat Zakirov  <m.zakirov@samsung.com>

* c-c++-common/asan/aggressive-opts.c: New test.

From-SVN: r217690

gcc/ChangeLog
gcc/opts.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/asan/aggressive-opts.c [new file with mode: 0644]

index c0649cf5d03a189e7ddfff27a708b0ad44634311..4877dc977479c08340f786106fc4f07700a58beb 100644 (file)
@@ -1,3 +1,8 @@
+2014-11-18  Marat Zakirov  <m.zakirov@samsung.com>
+
+       * opts.c (finish_options): Disable aggressive opts for sanitizer.  
+       (common_handle_option): Move code to finish_options.  
+
 2014-11-18  Yury Gribov  <y.gribov@samsung.com>
 
        PR sanitizer/63802
index d22882bf3a22405f7f60a8d17d4d31e06b6a2504..a83345b91e21fd5a02dd69252385695dedbc9a1a 100644 (file)
@@ -904,6 +904,19 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
 
   if (opts->x_flag_sanitize_recover & SANITIZE_LEAK)
     error_at (loc, "-fsanitize-recover=leak is not supported");
+
+  /* When instrumenting the pointers, we don't want to remove
+     the null pointer checks.  */
+  if (opts->x_flag_sanitize & (SANITIZE_NULL | SANITIZE_NONNULL_ATTRIBUTE
+                               | SANITIZE_RETURNS_NONNULL_ATTRIBUTE))
+    opts->x_flag_delete_null_pointer_checks = 0;
+
+  /* Aggressive compiler optimizations may cause false negatives.  */
+  if (opts->x_flag_sanitize)
+    {
+      opts->x_flag_aggressive_loop_optimizations = 0;
+      opts->x_flag_strict_overflow = 0;
+    }
 }
 
 #define LEFT_COLUMN    27
@@ -1622,12 +1635,6 @@ common_handle_option (struct gcc_options *opts,
        if (code != OPT_fsanitize_)
          break;
 
-       /* When instrumenting the pointers, we don't want to remove
-          the null pointer checks.  */
-       if (opts->x_flag_sanitize & (SANITIZE_NULL | SANITIZE_NONNULL_ATTRIBUTE
-                                    | SANITIZE_RETURNS_NONNULL_ATTRIBUTE))
-         opts->x_flag_delete_null_pointer_checks = 0;
-
        /* Kernel ASan implies normal ASan but does not yet support
           all features.  */
        if (opts->x_flag_sanitize & SANITIZE_KERNEL_ADDRESS)
index 8a924cc5f0e249939d65a1144270e3ecbf053945..fbae34cb8c053ee0739589197d45ee2fd6761e02 100644 (file)
@@ -1,3 +1,7 @@
+2014-11-18  Marat Zakirov  <m.zakirov@samsung.com>
+
+       * c-c++-common/asan/aggressive-opts.c: New test.
+
 2014-11-18  Yury Gribov  <y.gribov@samsung.com>
 
        PR sanitizer/63802
diff --git a/gcc/testsuite/c-c++-common/asan/aggressive-opts.c b/gcc/testsuite/c-c++-common/asan/aggressive-opts.c
new file mode 100644 (file)
index 0000000..979b611
--- /dev/null
@@ -0,0 +1,28 @@
+/* { dg-options "-fdump-tree-asan" } */
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O3" } } */
+
+int ext;
+
+int
+Perl_do_sv_dump()
+{
+    int freq[10];
+    int i;
+    int max = 0;
+
+    if (max < ext)
+      max = ext;
+    
+    for (i = 0; i <= max; i++)
+      if (freq[i])
+       ext = 0;
+
+    if (i > 20)
+      return freq[i];
+    else
+      return 0;    
+}
+
+/* { dg-final { scan-tree-dump-times "ASAN_CHECK" 2 "asan1" } } */
+/* { dg-final { cleanup-tree-dump "asan1" } } */