[llvm] a441645 - [tsan] Don't crash on vscale (#91018)

via llvm-commits llvm-commits at lists.llvm.org
Fri May 3 16:29:30 PDT 2024


Author: Vitaly Buka
Date: 2024-05-03T16:29:26-07:00
New Revision: a441645f80bed10927f00e1b0dc35666306ca8d5

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

LOG: [tsan] Don't crash on vscale (#91018)

Co-authored-by: Heejin Ahn <aheejin at gmail.com>

Added: 
    

Modified: 
    llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
    llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
index 956ebe8fc8b9a3..2f3de199f51d44 100644
--- a/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
@@ -803,6 +803,10 @@ bool ThreadSanitizer::instrumentAtomic(Instruction *I, const DataLayout &DL) {
 int ThreadSanitizer::getMemoryAccessFuncIndex(Type *OrigTy, Value *Addr,
                                               const DataLayout &DL) {
   assert(OrigTy->isSized());
+  if (OrigTy->isScalableTy()) {
+    // FIXME: support vscale.
+    return -1;
+  }
   uint32_t TypeSize = DL.getTypeStoreSizeInBits(OrigTy);
   if (TypeSize != 8  && TypeSize != 16 &&
       TypeSize != 32 && TypeSize != 64 && TypeSize != 128) {

diff  --git a/llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll b/llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll
index 60a423835f21f1..3aef34317b0bbd 100644
--- a/llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll
+++ b/llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll
@@ -108,6 +108,18 @@ define i32 @NakedTest(ptr %a) naked sanitize_thread {
   ret i32 %tmp1
 }
 
+; vscale is unsupported, just don't crash here.
+define void @test_load_store_i32(ptr %a, ptr %b) sanitize_thread {
+; CHECK-LABEL: define void @test_load_store_i32(
+; CHECK-SAME: ptr [[A:%.*]], ptr [[B:%.*]])
+; CHECK-NEXT:    [[TMP1:%.*]] = load <vscale x 4 x i32>, ptr [[A]], align 16
+; CHECK-NEXT:    store <vscale x 4 x i32> [[TMP1]], ptr [[B]], align 16
+; CHECK-NEXT:    ret void
+  %1 = load <vscale x 4 x i32>, ptr %a
+  store <vscale x 4 x i32> %1, ptr %b
+  ret void
+}
+
 declare void @foo() nounwind
 
 ; CHECK: define internal void @tsan.module_ctor()


        


More information about the llvm-commits mailing list