[compiler-rt] 6889592 - [NFC][sanitizer] Limit StackStore stack size/tag to 1 byte

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 23 16:56:51 PST 2021


Author: Vitaly Buka
Date: 2021-11-23T16:56:34-08:00
New Revision: 6889592ebcdea168f9e7a5dc91b8549527e4dbf7

URL: https://github.com/llvm/llvm-project/commit/6889592ebcdea168f9e7a5dc91b8549527e4dbf7
DIFF: https://github.com/llvm/llvm-project/commit/6889592ebcdea168f9e7a5dc91b8549527e4dbf7.diff

LOG: [NFC][sanitizer] Limit StackStore stack size/tag to 1 byte

Nothing uses more than 8bit now. So the rest of the headers can store other data.
kStackTraceMax is 256 now, but all sanitizers by default store just 20-30 frames here.

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_stack_store.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_stack_store.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stack_store.cpp
index e6c61d9b772c..d46047b9a495 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stack_store.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stack_store.cpp
@@ -16,13 +16,13 @@ namespace __sanitizer {
 
 namespace {
 struct StackTraceHeader {
-  static constexpr u32 kStackSizeBits = 16;
+  static constexpr u32 kStackSizeBits = 8;
 
-  u32 size;
-  u32 tag;
+  u8 size;
+  u8 tag;
   explicit StackTraceHeader(const StackTrace &trace)
-      : size(trace.size), tag(trace.tag) {
-    CHECK_LT(trace.size, 1 << kStackSizeBits);
+      : size(Min<uptr>(trace.size, (1u << 8) - 1)), tag(trace.tag) {
+    CHECK_EQ(trace.tag, static_cast<uptr>(tag));
   }
   explicit StackTraceHeader(uptr h)
       : size(h & ((1 << kStackSizeBits) - 1)), tag(h >> kStackSizeBits) {}

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h
index 11c6154b09ea..aebd504669d2 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h
@@ -20,7 +20,7 @@ namespace __sanitizer {
 
 struct BufferedStackTrace;
 
-static const u32 kStackTraceMax = 256;
+static const u32 kStackTraceMax = 255;
 
 #if SANITIZER_LINUX && defined(__mips__)
 # define SANITIZER_CAN_FAST_UNWIND 0


        


More information about the llvm-commits mailing list