Mercurial > hg > CbC > CbC_gcc
diff gcc/sanopt.c @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 84e7813d76e9 |
children |
line wrap: on
line diff
--- a/gcc/sanopt.c Thu Oct 25 07:37:49 2018 +0900 +++ b/gcc/sanopt.c Thu Feb 13 11:34:05 2020 +0900 @@ -1,5 +1,5 @@ /* Optimize and expand sanitizer functions. - Copyright (C) 2014-2018 Free Software Foundation, Inc. + Copyright (C) 2014-2020 Free Software Foundation, Inc. Contributed by Marek Polacek <polacek@redhat.com> This file is part of GCC. @@ -34,7 +34,6 @@ #include "attribs.h" #include "asan.h" #include "ubsan.h" -#include "params.h" #include "tree-hash-traits.h" #include "gimple-ssa.h" #include "tree-phinodes.h" @@ -130,6 +129,8 @@ ref.t1 = reinterpret_cast<tree> (1); } + static const bool empty_zero_p = true; + static void mark_empty (sanopt_tree_triplet &ref) { @@ -185,6 +186,8 @@ ref.ptr = reinterpret_cast<tree> (1); } + static const bool empty_zero_p = true; + static void mark_empty (sanopt_tree_couple &ref) { @@ -207,8 +210,9 @@ /* This is used to carry various hash maps and variables used in sanopt_optimize_walker. */ -struct sanopt_ctx +class sanopt_ctx { +public: /* This map maps a pointer (the first argument of UBSAN_NULL) to a vector of UBSAN_NULL call statements that check this pointer. */ hash_map<tree, auto_vec<gimple *> > null_check_map; @@ -353,7 +357,7 @@ /* Optimize away redundant UBSAN_NULL calls. */ static bool -maybe_optimize_ubsan_null_ifn (struct sanopt_ctx *ctx, gimple *stmt) +maybe_optimize_ubsan_null_ifn (class sanopt_ctx *ctx, gimple *stmt) { gcc_assert (gimple_call_num_args (stmt) == 3); tree ptr = gimple_call_arg (stmt, 0); @@ -590,7 +594,7 @@ when we can actually optimize. */ static bool -maybe_optimize_ubsan_vptr_ifn (struct sanopt_ctx *ctx, gimple *stmt) +maybe_optimize_ubsan_vptr_ifn (class sanopt_ctx *ctx, gimple *stmt) { gcc_assert (gimple_call_num_args (stmt) == 5); sanopt_tree_triplet triplet; @@ -694,7 +698,7 @@ /* Optimize away redundant ASAN_CHECK calls. */ static bool -maybe_optimize_asan_check_ifn (struct sanopt_ctx *ctx, gimple *stmt) +maybe_optimize_asan_check_ifn (class sanopt_ctx *ctx, gimple *stmt) { gcc_assert (gimple_call_num_args (stmt) == 4); tree ptr = gimple_call_arg (stmt, 1); @@ -767,7 +771,7 @@ anything anymore. CTX is a sanopt context. */ static void -sanopt_optimize_walker (basic_block bb, struct sanopt_ctx *ctx) +sanopt_optimize_walker (basic_block bb, class sanopt_ctx *ctx) { basic_block son; gimple_stmt_iterator gsi; @@ -886,7 +890,7 @@ static int sanopt_optimize (function *fun, bool *contains_asan_mark) { - struct sanopt_ctx ctx; + class sanopt_ctx ctx; ctx.asan_num_accesses = 0; ctx.contains_asan_mark = false; @@ -1170,9 +1174,12 @@ continue; if (dump_file) - fprintf (dump_file, - "Rewriting parameter whose address is taken: %s\n", - IDENTIFIER_POINTER (DECL_NAME (arg))); + { + fprintf (dump_file, + "Rewriting parameter whose address is taken: "); + print_generic_expr (dump_file, arg, dump_flags); + fputc ('\n', dump_file); + } SET_DECL_PT_UID (var, DECL_PT_UID (arg)); @@ -1288,8 +1295,8 @@ if (asan_sanitize_stack_p ()) sanitize_rewrite_addressable_params (fun); - bool use_calls = ASAN_INSTRUMENTATION_WITH_CALL_THRESHOLD < INT_MAX - && asan_num_accesses >= ASAN_INSTRUMENTATION_WITH_CALL_THRESHOLD; + bool use_calls = param_asan_instrumentation_with_call_threshold < INT_MAX + && asan_num_accesses >= param_asan_instrumentation_with_call_threshold; hash_map<tree, tree> shadow_vars_mapping; bool need_commit_edge_insert = false;