[compiler-rt] 7de73da - [asan] Modified ASAN_MEMORY_ACCESS_CALLBACK to use a function call to ReportGenericErrorWrapper.

Kirill Stoimenov via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 22 14:20:42 PDT 2021


Author: Kirill Stoimenov
Date: 2021-07-22T21:20:24Z
New Revision: 7de73da8dad3ee6c5bca676b679bcdab84050ea2

URL: https://github.com/llvm/llvm-project/commit/7de73da8dad3ee6c5bca676b679bcdab84050ea2
DIFF: https://github.com/llvm/llvm-project/commit/7de73da8dad3ee6c5bca676b679bcdab84050ea2.diff

LOG: [asan] Modified ASAN_MEMORY_ACCESS_CALLBACK to use a function call to ReportGenericErrorWrapper.

This change eliminate the stack frame for the fast path and improves runtime performance.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D106505

Added: 
    

Modified: 
    compiler-rt/lib/asan/asan_rtl.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/asan/asan_rtl.cpp b/compiler-rt/lib/asan/asan_rtl.cpp
index e06a1113f4edc..bfaa3bc270274 100644
--- a/compiler-rt/lib/asan/asan_rtl.cpp
+++ b/compiler-rt/lib/asan/asan_rtl.cpp
@@ -82,6 +82,17 @@ void ShowStatsAndAbort() {
   Die();
 }
 
+NOINLINE
+static void ReportGenericErrorWrapper(uptr addr, bool is_write, int size,
+                                      int exp_arg, bool fatal) {
+  if (__asan_test_only_reported_buggy_pointer) {
+    *__asan_test_only_reported_buggy_pointer = addr;
+  } else {
+    GET_CALLER_PC_BP_SP;
+    ReportGenericError(pc, bp, sp, addr, is_write, size, exp_arg, fatal);
+  }
+}
+
 // --------------- LowLevelAllocateCallbac ---------- {{{1
 static void OnLowLevelAllocate(uptr ptr, uptr size) {
   PoisonShadow(ptr, size, kAsanInternalHeapMagic);
@@ -145,12 +156,7 @@ ASAN_REPORT_ERROR_N(store, true)
     if (UNLIKELY(size >= SHADOW_GRANULARITY ||                                 \
                  ((s8)((addr & (SHADOW_GRANULARITY - 1)) + size - 1)) >=       \
                      (s8)s)) {                                                 \
-      if (__asan_test_only_reported_buggy_pointer) {                           \
-        *__asan_test_only_reported_buggy_pointer = addr;                       \
-      } else {                                                                 \
-        GET_CALLER_PC_BP_SP;                                                   \
-        ReportGenericError(pc, bp, sp, addr, is_write, size, exp_arg, fatal);  \
-      }                                                                        \
+      ReportGenericErrorWrapper(addr, is_write, size, exp_arg, fatal);         \
     }                                                                          \
   }
 


        


More information about the llvm-commits mailing list