Skip to content

[tsan] Don't crash on vscale #91018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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