Do not disable aggressive loop opts for
authorMartin Liska <mliska@suse.cz>
Mon, 24 Oct 2016 07:00:53 +0000 (09:00 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Mon, 24 Oct 2016 07:00:53 +0000 (07:00 +0000)
PR sanitizer/77966
* opts.c (finish_options): Skip conditionally.
PR sanitizer/77966
* c-c++-common/ubsan/unreachable-3.c: New test.

From-SVN: r241463

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

index 4c4583ecc5ca8ee63f704f2dae4d908429e472de..e654d8a1fd86edd12c9052704d578c1885d5247d 100644 (file)
@@ -1,3 +1,8 @@
+2016-10-24  Martin Liska  <mliska@suse.cz>
+
+       PR sanitizer/77966
+       * opts.c (finish_options): Skip conditionally.
+
 2016-10-23  Martin Sebor  <msebor@redhat.com>
 
        PR target/77837
index 5f447500a9fe89a8ddb0b2f14278bab8a15b45c2..6b34473d1a460180cf2699aeba1158c8e0943d85 100644 (file)
@@ -973,7 +973,7 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
     opts->x_flag_delete_null_pointer_checks = 0;
 
   /* Aggressive compiler optimizations may cause false negatives.  */
-  if (opts->x_flag_sanitize)
+  if (opts->x_flag_sanitize & ~(SANITIZE_LEAK | SANITIZE_UNREACHABLE))
     {
       opts->x_flag_aggressive_loop_optimizations = 0;
       opts->x_flag_strict_overflow = 0;
index 35da701d7ea6501c9707499f6357adf6c98ef88f..97fca4001cd089a3fb0fe90049c66243d3772007 100644 (file)
@@ -1,3 +1,8 @@
+2016-10-24  Martin Liska  <mliska@suse.cz>
+
+       PR sanitizer/77966
+       * c-c++-common/ubsan/unreachable-3.c: New test.
+
 2016-10-23  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/77763
diff --git a/gcc/testsuite/c-c++-common/ubsan/unreachable-3.c b/gcc/testsuite/c-c++-common/ubsan/unreachable-3.c
new file mode 100644 (file)
index 0000000..b7a0d1a
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=unreachable -O2 -fno-reorder-blocks -fsanitize-coverage=trace-pc -fdump-tree-optimized" } */
+/* { dg-skip-if "" { *-*-* } { "-flto" } } */
+
+extern unsigned int ioread32(void *);
+struct vnic_wq_ctrl {
+    unsigned int error_status;
+};
+struct snic {
+    unsigned int wq_count;
+    struct vnic_wq_ctrl *wq[1];
+    int wq_lock[1];
+};
+void snic_log_q_error(struct snic *snic)
+{
+    unsigned int i;
+    for (i = 0; i < snic->wq_count; i++)
+        ioread32(&snic->wq[i]->error_status);
+}
+
+/* { dg-final { scan-tree-dump "__builtin___ubsan_handle_builtin_unreachable" "optimized" } } */