Skip to content

Commit 34db894

Browse files
committed
1 parent 390b236 commit 34db894

File tree

8 files changed

+34
-38
lines changed

8 files changed

+34
-38
lines changed

gcc/asan.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3190,9 +3190,9 @@ asan_instrument (void)
31903190
}
31913191

31923192
static bool
3193-
gate_asan (function *fn)
3193+
gate_asan ()
31943194
{
3195-
return sanitize_flags_p (SANITIZE_ADDRESS, fn->decl);
3195+
return sanitize_flags_p (SANITIZE_ADDRESS);
31963196
}
31973197

31983198
namespace {
@@ -3219,7 +3219,7 @@ class pass_asan : public gimple_opt_pass
32193219

32203220
/* opt_pass methods: */
32213221
opt_pass * clone () { return new pass_asan (m_ctxt); }
3222-
virtual bool gate (function *fn) { return gate_asan (fn); }
3222+
virtual bool gate (function *) { return gate_asan (); }
32233223
virtual unsigned int execute (function *) { return asan_instrument (); }
32243224

32253225
}; // class pass_asan
@@ -3255,7 +3255,7 @@ class pass_asan_O0 : public gimple_opt_pass
32553255
{}
32563256

32573257
/* opt_pass methods: */
3258-
virtual bool gate (function *fn) { return !optimize && gate_asan (fn); }
3258+
virtual bool gate (function *) { return !optimize && gate_asan (); }
32593259
virtual unsigned int execute (function *) { return asan_instrument (); }
32603260

32613261
}; // class pass_asan_O0

gcc/c-family/c-attribs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,8 @@ handle_cold_attribute (tree *node, tree name, tree ARG_UNUSED (args),
553553
return NULL_TREE;
554554
}
555555

556+
/* Exclude FLAGS from options enabled by -fsanitize. */
557+
556558
void
557559
add_no_sanitize_value (unsigned int flags)
558560
{

gcc/cp/decl2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3737,7 +3737,7 @@ one_static_initialization_or_destruction (tree decl, tree init, bool initp)
37373737
if (init)
37383738
{
37393739
finish_expr_stmt (init);
3740-
if (sanitize_flags_p (SANITIZE_ADDRESS, decl))
3740+
if (sanitize_flags_p (SANITIZE_ADDRESS))
37413741
{
37423742
varpool_node *vnode = varpool_node::get (decl);
37433743
if (vnode)

gcc/ipa-inline.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -252,18 +252,6 @@ report_inline_failed_reason (struct cgraph_edge *e)
252252
}
253253
}
254254

255-
/* Decide whether sanitizer-related attributes allow inlining. */
256-
257-
static bool
258-
sanitize_attrs_match_for_inline_p (const_tree caller, const_tree callee)
259-
{
260-
if (!caller || !callee)
261-
return true;
262-
263-
return sanitize_flags_p (SANITIZE_ADDRESS, caller)
264-
== sanitize_flags_p (SANITIZE_ADDRESS, callee);
265-
}
266-
267255
/* Used for flags where it is safe to inline when caller's value is
268256
grater than callee's. */
269257
#define check_maybe_up(flag) \
@@ -285,6 +273,18 @@ sanitize_attrs_match_for_inline_p (const_tree caller, const_tree callee)
285273
(opts_for_fn (caller->decl)->x_##flag \
286274
!= opts_for_fn (callee->decl)->x_##flag)
287275

276+
/* Decide whether sanitizer-related attributes allow inlining. */
277+
278+
static bool
279+
sanitize_attrs_match_for_inline_p (const_tree caller, const_tree callee)
280+
{
281+
if (!caller || !callee)
282+
return true;
283+
284+
return ((opts_for_fn (caller)->x_flag_sanitize_local & SANITIZE_ADDRESS)
285+
== (opts_for_fn (callee)->x_flag_sanitize_local & SANITIZE_ADDRESS));
286+
}
287+
288288
/* Decide if we can inline the edge and possibly update
289289
inline_failed reason.
290290
We check whether inlining is possible at all and whether

gcc/tree.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14442,14 +14442,9 @@ nonnull_arg_p (const_tree arg)
1444214442
return false;
1444314443
}
1444414444

14445-
/* Return true when flag_sanitize & FLAG is non-zero. */
14446-
1444714445
bool
14448-
sanitize_flags_p (unsigned int flag, const_tree fn)
14446+
sanitize_flags_p (unsigned int flag)
1444914447
{
14450-
if (fn == NULL)
14451-
return false;
14452-
1445314448
return flag_sanitize_local & flag;
1445414449
}
1445514450

gcc/tree.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4248,9 +4248,8 @@ extern tree merge_dllimport_decl_attributes (tree, tree);
42484248
/* Handle a "dllimport" or "dllexport" attribute. */
42494249
extern tree handle_dll_attribute (tree *, tree, tree, int, bool *);
42504250

4251-
4252-
extern bool sanitize_flags_p (unsigned int flag,
4253-
const_tree fn = current_function_decl);
4251+
/* Return true when FLAG is enabled in -fsanitize option values. */
4252+
extern bool sanitize_flags_p (unsigned int flag);
42544253

42554254
/* Returns true iff CAND and BASE have equivalent language-specific
42564255
qualifiers. */

gcc/tsan.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -894,9 +894,9 @@ class pass_tsan : public gimple_opt_pass
894894

895895
/* opt_pass methods: */
896896
opt_pass * clone () { return new pass_tsan (m_ctxt); }
897-
virtual bool gate (function *fn)
897+
virtual bool gate (function *)
898898
{
899-
return sanitize_flags_p (SANITIZE_THREAD, fn->decl);
899+
return sanitize_flags_p (SANITIZE_THREAD);
900900
}
901901

902902
virtual unsigned int execute (function *) { return tsan_pass (); }
@@ -934,9 +934,9 @@ class pass_tsan_O0 : public gimple_opt_pass
934934
{}
935935

936936
/* opt_pass methods: */
937-
virtual bool gate (function *fn)
937+
virtual bool gate (function *)
938938
{
939-
return (sanitize_flags_p (SANITIZE_THREAD, fn->decl) && !optimize);
939+
return (sanitize_flags_p (SANITIZE_THREAD) && !optimize);
940940
}
941941

942942
virtual unsigned int execute (function *) { return tsan_pass (); }

gcc/ubsan.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,14 +1949,14 @@ class pass_ubsan : public gimple_opt_pass
19491949
{}
19501950

19511951
/* opt_pass methods: */
1952-
virtual bool gate (function *fn)
1952+
virtual bool gate (function *)
19531953
{
19541954
return sanitize_flags_p ((SANITIZE_NULL | SANITIZE_SI_OVERFLOW
19551955
| SANITIZE_BOOL | SANITIZE_ENUM
19561956
| SANITIZE_ALIGNMENT
19571957
| SANITIZE_NONNULL_ATTRIBUTE
19581958
| SANITIZE_RETURNS_NONNULL_ATTRIBUTE
1959-
| SANITIZE_OBJECT_SIZE), fn->decl);
1959+
| SANITIZE_OBJECT_SIZE));
19601960
}
19611961

19621962
virtual unsigned int execute (function *);
@@ -1983,41 +1983,41 @@ pass_ubsan::execute (function *fun)
19831983
continue;
19841984
}
19851985

1986-
if ((sanitize_flags_p (SANITIZE_SI_OVERFLOW, fun->decl))
1986+
if ((sanitize_flags_p (SANITIZE_SI_OVERFLOW))
19871987
&& is_gimple_assign (stmt))
19881988
instrument_si_overflow (gsi);
19891989

1990-
if (sanitize_flags_p (SANITIZE_NULL | SANITIZE_ALIGNMENT, fun->decl))
1990+
if (sanitize_flags_p (SANITIZE_NULL | SANITIZE_ALIGNMENT))
19911991
{
19921992
if (gimple_store_p (stmt))
19931993
instrument_null (gsi, true);
19941994
if (gimple_assign_single_p (stmt))
19951995
instrument_null (gsi, false);
19961996
}
19971997

1998-
if (sanitize_flags_p (SANITIZE_BOOL | SANITIZE_ENUM, fun->decl)
1998+
if (sanitize_flags_p (SANITIZE_BOOL | SANITIZE_ENUM)
19991999
&& gimple_assign_load_p (stmt))
20002000
{
20012001
instrument_bool_enum_load (&gsi);
20022002
bb = gimple_bb (stmt);
20032003
}
20042004

2005-
if (sanitize_flags_p (SANITIZE_NONNULL_ATTRIBUTE, fun->decl)
2005+
if (sanitize_flags_p (SANITIZE_NONNULL_ATTRIBUTE)
20062006
&& is_gimple_call (stmt)
20072007
&& !gimple_call_internal_p (stmt))
20082008
{
20092009
instrument_nonnull_arg (&gsi);
20102010
bb = gimple_bb (stmt);
20112011
}
20122012

2013-
if (sanitize_flags_p (SANITIZE_RETURNS_NONNULL_ATTRIBUTE, fun->decl)
2013+
if (sanitize_flags_p (SANITIZE_RETURNS_NONNULL_ATTRIBUTE)
20142014
&& gimple_code (stmt) == GIMPLE_RETURN)
20152015
{
20162016
instrument_nonnull_return (&gsi);
20172017
bb = gimple_bb (stmt);
20182018
}
20192019

2020-
if (sanitize_flags_p (SANITIZE_OBJECT_SIZE, fun->decl))
2020+
if (sanitize_flags_p (SANITIZE_OBJECT_SIZE))
20212021
{
20222022
if (gimple_store_p (stmt))
20232023
instrument_object_size (&gsi, true);

0 commit comments

Comments
 (0)