Skip to content

Commit

Permalink
[tsan] Don't crash on vscale (#91018)
Browse files Browse the repository at this point in the history
Co-authored-by: Heejin Ahn <aheejin@gmail.com>
  • Loading branch information
vitalybuka and aheejin committed May 3, 2024
1 parent e5cbe8f commit a441645
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 12 additions & 0 deletions llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit a441645

Please sign in to comment.