re PR sanitizer/83219 (c-c++-common/ubsan/unreachable-2.c fails starting with r255201)
authorJakub Jelinek <jakub@redhat.com>
Fri, 1 Dec 2017 08:08:55 +0000 (09:08 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 1 Dec 2017 08:08:55 +0000 (09:08 +0100)
PR sanitizer/83219
* tree-cfg.c: Include asan.h.
(gimple_seq_unreachable_p): Return false for -fsanitize=unreachable.

From-SVN: r255295

gcc/ChangeLog
gcc/tree-cfg.c

index e38b73f6bc0e97d3c1c3a55920095c43de523a48..e77936e2f707d7893785d4d7e7ea98bb956323a0 100644 (file)
@@ -1,3 +1,9 @@
+2017-12-01  Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/83219
+       * tree-cfg.c: Include asan.h.
+       (gimple_seq_unreachable_p): Return false for -fsanitize=unreachable.
+
 2017-12-01  Sergey Shalnov  <Sergey.Shalnov@intel.com>
 
        * config/i386/i386.md: Fix AVX512 register width in AVX512 instruction.
index 2835a4b722c21f0ced3542a505cdd56fae0bb37d..92f3201f4a4dd1b4f9e3236049c527bd862224af 100644 (file)
@@ -61,6 +61,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "attribs.h"
 #include "selftest.h"
 #include "opts.h"
+#include "asan.h"
 
 /* This file contains functions for building the Control Flow Graph (CFG)
    for a function tree.  */
@@ -469,7 +470,12 @@ computed_goto_p (gimple *t)
 bool
 gimple_seq_unreachable_p (gimple_seq stmts)
 {
-  if (stmts == NULL)
+  if (stmts == NULL
+      /* Return false if -fsanitize=unreachable, we don't want to
+        optimize away those calls, but rather turn them into
+        __ubsan_handle_builtin_unreachable () or __builtin_trap ()
+        later.  */
+      || sanitize_flags_p (SANITIZE_UNREACHABLE))
     return false;
 
   gimple_stmt_iterator gsi = gsi_last (stmts);