On November 30, 2017 11:51:09 PM GMT+01:00, Jakub Jelinek <ja...@redhat.com> 
wrote:
>Hi!
>
>As mentioned in the PR, when -fsanitize=unreachable (part of
>-fsanitize=undefined), we don't want optimizers to optimize away
>conditional branches to __builtin_unreachable or switch cases
>that branch go __builtin_unreachable.
>
>Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok
>for
>trunk?

OK. 

Richard. 

>2017-11-30  Jakub Jelinek  <ja...@redhat.com>
>
>       PR sanitizer/83219
>       * tree-cfg.c: Include asan.h.
>       (gimple_seq_unreachable_p): Return false for -fsanitize=unreachable.
>
>--- gcc/tree-cfg.c.jj  2017-11-23 21:13:30.000000000 +0100
>+++ gcc/tree-cfg.c     2017-11-30 11:40:38.334930487 +0100
>@@ -61,6 +61,7 @@ along with GCC; see the file COPYING3.
> #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);
>
>       Jakub

Reply via email to