[PATCH] D70683: [GWP-ASan] Add GWP_ASAN_ prefix to macros.
Mitch Phillips via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 25 10:35:08 PST 2019
hctim created this revision.
hctim added a reviewer: eugenis.
Herald added projects: Sanitizers, LLVM.
Herald added subscribers: llvm-commits, Sanitizers.
When platforms use their own `LIKELY()` definitions, it can be quite
troublesome to ensure they don't conflict with the GWP-ASan internal
definitions. Just force the GWP_ASAN_ prefix to help this issue.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D70683
Files:
compiler-rt/lib/gwp_asan/definitions.h
compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
Index: compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
===================================================================
--- compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
+++ compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
@@ -100,19 +100,19 @@
void init(const options::Options &Opts);
// Return whether the allocation should be randomly chosen for sampling.
- ALWAYS_INLINE bool shouldSample() {
+ GWP_ASAN_ALWAYS_INLINE bool shouldSample() {
// NextSampleCounter == 0 means we "should regenerate the counter".
// == 1 means we "should sample this allocation".
- if (UNLIKELY(ThreadLocals.NextSampleCounter == 0))
+ if (GWP_ASAN_UNLIKELY(ThreadLocals.NextSampleCounter == 0))
ThreadLocals.NextSampleCounter =
(getRandomUnsigned32() % AdjustedSampleRate) + 1;
- return UNLIKELY(--ThreadLocals.NextSampleCounter == 0);
+ return GWP_ASAN_UNLIKELY(--ThreadLocals.NextSampleCounter == 0);
}
// Returns whether the provided pointer is a current sampled allocation that
// is owned by this pool.
- ALWAYS_INLINE bool pointerIsMine(const void *Ptr) const {
+ GWP_ASAN_ALWAYS_INLINE bool pointerIsMine(const void *Ptr) const {
uintptr_t P = reinterpret_cast<uintptr_t>(Ptr);
return GuardedPagePool <= P && P < GuardedPagePoolEnd;
}
@@ -267,7 +267,7 @@
// allocation.
bool RecursiveGuard = false;
};
- static TLS_INITIAL_EXEC ThreadLocalPackedVariables ThreadLocals;
+ static GWP_ASAN_TLS_INITIAL_EXEC ThreadLocalPackedVariables ThreadLocals;
};
} // namespace gwp_asan
Index: compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
===================================================================
--- compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
+++ compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
@@ -527,7 +527,7 @@
printAllocDeallocTraces(AccessPtr, Meta, Printf, PrintBacktrace);
}
-TLS_INITIAL_EXEC
+GWP_ASAN_TLS_INITIAL_EXEC
GuardedPoolAllocator::ThreadLocalPackedVariables
GuardedPoolAllocator::ThreadLocals;
} // namespace gwp_asan
Index: compiler-rt/lib/gwp_asan/definitions.h
===================================================================
--- compiler-rt/lib/gwp_asan/definitions.h
+++ compiler-rt/lib/gwp_asan/definitions.h
@@ -9,21 +9,9 @@
#ifndef GWP_ASAN_DEFINITIONS_H_
#define GWP_ASAN_DEFINITIONS_H_
-#define TLS_INITIAL_EXEC __thread __attribute__((tls_model("initial-exec")))
+#define GWP_ASAN_TLS_INITIAL_EXEC __thread __attribute__((tls_model("initial-exec")))
-#ifdef LIKELY
-# undef LIKELY
-#endif // defined(LIKELY)
-#define LIKELY(X) __builtin_expect(!!(X), 1)
-
-#ifdef UNLIKELY
-# undef UNLIKELY
-#endif // defined(UNLIKELY)
-#define UNLIKELY(X) __builtin_expect(!!(X), 0)
-
-#ifdef ALWAYS_INLINE
-# undef ALWAYS_INLINE
-#endif // defined(ALWAYS_INLINE)
-#define ALWAYS_INLINE inline __attribute__((always_inline))
+#define GWP_ASAN_UNLIKELY(X) __builtin_expect(!!(X), 0)
+#define GWP_ASAN_ALWAYS_INLINE inline __attribute__((always_inline))
#endif // GWP_ASAN_DEFINITIONS_H_
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70683.230931.patch
Type: text/x-patch
Size: 3058 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191125/8f3cbd83/attachment.bin>
More information about the llvm-commits
mailing list