/* AddressSanitizer, a fast memory error detector.
- Copyright (C) 2011-2023 Free Software Foundation, Inc.
+ Copyright (C) 2011-2024 Free Software Foundation, Inc.
Contributed by Kostya Serebryany <kcc@google.com>
This file is part of GCC.
extern bool asan_expand_mark_ifn (gimple_stmt_iterator *);
extern bool asan_expand_poison_ifn (gimple_stmt_iterator *, bool *,
hash_map<tree, tree> &);
+extern rtx asan_memfn_rtl (tree);
extern void hwasan_record_frame_init ();
extern void hwasan_record_stack_var (rtx, rtx, poly_int64, poly_int64);
/* Return the size of padding needed to insert after a protected
decl of SIZE. */
-static inline unsigned int
+inline unsigned int
asan_red_zone_size (unsigned int size)
{
unsigned int c = size & (ASAN_RED_ZONE_SIZE - 1);
/* Return how much a stack variable occupis on a stack
including a space for red zone. */
-static inline unsigned HOST_WIDE_INT
+inline unsigned HOST_WIDE_INT
asan_var_and_redzone_size (unsigned HOST_WIDE_INT size)
{
if (size <= 4)
/* Return TRUE if builtin with given FCODE will be intercepted by
libasan. */
-static inline bool
+inline bool
asan_intercepted_p (enum built_in_function fcode)
{
+ /* This list should be kept up-to-date with upstream's version at
+ compiler-rt/lib/hwasan/hwasan_platform_interceptors.h. */
if (hwasan_sanitize_p ())
- return false;
+ return fcode == BUILT_IN_MEMCMP
+ || fcode == BUILT_IN_MEMCPY
+ || fcode == BUILT_IN_MEMMOVE
+ || fcode == BUILT_IN_MEMSET;
return fcode == BUILT_IN_INDEX
|| fcode == BUILT_IN_MEMCHR
/* Return TRUE if we should instrument for use-after-scope sanity checking. */
-static inline bool
+inline bool
asan_sanitize_use_after_scope (void)
{
return (flag_sanitize_address_use_after_scope
/* Return true if DECL should be guarded on the stack. */
-static inline bool
+inline bool
asan_protect_stack_decl (tree decl)
{
return DECL_P (decl)
/* Return true when flag_sanitize & FLAG is non-zero. If FN is non-null,
remove all flags mentioned in "no_sanitize" of DECL_ATTRIBUTES. */
-static inline bool
+inline bool
sanitize_flags_p (unsigned int flag, const_tree fn = current_function_decl)
{
unsigned int result_flags = flag_sanitize & flag;
/* Return true when coverage sanitization should happend for FN function. */
-static inline bool
+inline bool
sanitize_coverage_p (const_tree fn = current_function_decl)
{
return (flag_sanitize_coverage