Skip to content

Commit a441645

Browse files
vitalybukaaheejin
andauthored
[tsan] Don't crash on vscale (#91018)
Co-authored-by: Heejin Ahn <[email protected]>
1 parent e5cbe8f commit a441645

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,10 @@ bool ThreadSanitizer::instrumentAtomic(Instruction *I, const DataLayout &DL) {
803803
int ThreadSanitizer::getMemoryAccessFuncIndex(Type *OrigTy, Value *Addr,
804804
const DataLayout &DL) {
805805
assert(OrigTy->isSized());
806+
if (OrigTy->isScalableTy()) {
807+
// FIXME: support vscale.
808+
return -1;
809+
}
806810
uint32_t TypeSize = DL.getTypeStoreSizeInBits(OrigTy);
807811
if (TypeSize != 8 && TypeSize != 16 &&
808812
TypeSize != 32 && TypeSize != 64 && TypeSize != 128) {

llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@ define i32 @NakedTest(ptr %a) naked sanitize_thread {
108108
ret i32 %tmp1
109109
}
110110

111+
; vscale is unsupported, just don't crash here.
112+
define void @test_load_store_i32(ptr %a, ptr %b) sanitize_thread {
113+
; CHECK-LABEL: define void @test_load_store_i32(
114+
; CHECK-SAME: ptr [[A:%.*]], ptr [[B:%.*]])
115+
; CHECK-NEXT: [[TMP1:%.*]] = load <vscale x 4 x i32>, ptr [[A]], align 16
116+
; CHECK-NEXT: store <vscale x 4 x i32> [[TMP1]], ptr [[B]], align 16
117+
; CHECK-NEXT: ret void
118+
%1 = load <vscale x 4 x i32>, ptr %a
119+
store <vscale x 4 x i32> %1, ptr %b
120+
ret void
121+
}
122+
111123
declare void @foo() nounwind
112124

113125
; CHECK: define internal void @tsan.module_ctor()

0 commit comments

Comments
 (0)