From 770cf505a1c1676f6d4c6968ddd05c5ea0f3af27 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 1 Dec 2017 09:08:55 +0100 Subject: [PATCH] re PR sanitizer/83219 (c-c++-common/ubsan/unreachable-2.c fails starting with r255201) PR sanitizer/83219 * tree-cfg.c: Include asan.h. (gimple_seq_unreachable_p): Return false for -fsanitize=unreachable. From-SVN: r255295 --- gcc/ChangeLog | 6 ++++++ gcc/tree-cfg.c | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e38b73f6bc0..e77936e2f70 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-12-01 Jakub Jelinek + + PR sanitizer/83219 + * tree-cfg.c: Include asan.h. + (gimple_seq_unreachable_p): Return false for -fsanitize=unreachable. + 2017-12-01 Sergey Shalnov * config/i386/i386.md: Fix AVX512 register width in AVX512 instruction. diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 2835a4b722c..92f3201f4a4 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -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); -- 2.30.2