[compiler-rt] 1959a55 - [ubsan-minimal][NFC] Use GET_CALLER_PC() to get the return address
Igor Kudrin via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 23 10:40:21 PDT 2022
Author: Igor Kudrin
Date: 2022-08-23T21:39:27+04:00
New Revision: 1959a55591dac8f698b6c86cb39724a1a13484ab
URL: https://github.com/llvm/llvm-project/commit/1959a55591dac8f698b6c86cb39724a1a13484ab
DIFF: https://github.com/llvm/llvm-project/commit/1959a55591dac8f698b6c86cb39724a1a13484ab.diff
LOG: [ubsan-minimal][NFC] Use GET_CALLER_PC() to get the return address
This is a preparation step for D131914.
Added:
Modified:
compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp b/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
index 6a1903da62ce7..5301a5183b92d 100644
--- a/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
+++ b/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
@@ -20,9 +20,9 @@ static __sanitizer::atomic_uintptr_t caller_pcs[kMaxCallerPcs];
// that "too many errors" has already been reported.
static __sanitizer::atomic_uint32_t caller_pcs_sz;
-__attribute__((noinline)) static bool report_this_error(void *caller_p) {
- uintptr_t caller = reinterpret_cast<uintptr_t>(caller_p);
- if (caller == 0) return false;
+__attribute__((noinline)) static bool report_this_error(uintptr_t caller) {
+ if (caller == 0)
+ return false;
while (true) {
unsigned sz = __sanitizer::atomic_load_relaxed(&caller_pcs_sz);
if (sz > kMaxCallerPcs) return false; // early exit
@@ -80,7 +80,7 @@ void NORETURN CheckFailed(const char *file, int, const char *cond, u64, u64) {
// @1234ABCD").
#define HANDLER_RECOVER(name, msg) \
INTERFACE void __ubsan_handle_##name##_minimal() { \
- if (!report_this_error(__builtin_return_address(0))) return; \
+ if (!report_this_error(GET_CALLER_PC())) return; \
message("ubsan: " msg "\n"); \
}
More information about the llvm-commits
mailing list