diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 50258af5e26c3..42c3d4a4f4c46 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1219,7 +1219,9 @@ struct FunctionStackPoisoner : public InstVisitor { std::optional Size = AI->getAllocationSize(AI->getDataLayout()); // Check that size is known and can be stored in IntptrTy. - if (!Size || !ConstantInt::isValueValidForType(IntptrTy, *Size)) + // TODO: Add support for scalable vectors if possible. + if (!Size || Size->isScalable() || + !ConstantInt::isValueValidForType(IntptrTy, *Size)) return; bool DoPoison = (ID == Intrinsic::lifetime_end); diff --git a/llvm/test/Instrumentation/AddressSanitizer/asan-scalable-vector.ll b/llvm/test/Instrumentation/AddressSanitizer/asan-scalable-vector.ll new file mode 100644 index 0000000000000..6a841f2d399c0 --- /dev/null +++ b/llvm/test/Instrumentation/AddressSanitizer/asan-scalable-vector.ll @@ -0,0 +1,27 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 +; RUN: opt < %s -passes='asan' -S | FileCheck %s + +define void @test() #1 { +; CHECK-LABEL: define void @test( +; CHECK-SAME: ) #[[ATTR0:[0-9]+]] { +; CHECK-NEXT: [[ENTRY:.*:]] +; CHECK-NEXT: [[CTX_PG:%.*]] = alloca , align 2 +; CHECK-NEXT: call void @llvm.lifetime.start.p0(ptr [[CTX_PG]]) +; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr inttoptr (i64 17592186044416 to ptr), align 1 +; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i8 [[TMP0]], 0 +; CHECK-NEXT: br i1 [[TMP1]], label %[[BB2:.*]], label %[[BB3:.*]] +; CHECK: [[BB2]]: +; CHECK-NEXT: call void @__asan_report_store8(i64 0) #[[ATTR4:[0-9]+]] +; CHECK-NEXT: unreachable +; CHECK: [[BB3]]: +; CHECK-NEXT: store ptr [[CTX_PG]], ptr null, align 8 +; CHECK-NEXT: ret void +; +entry: + %ctx_pg = alloca , align 2 + call void @llvm.lifetime.start.p0(ptr %ctx_pg) + store ptr %ctx_pg, ptr null, align 8 + ret void +} + +attributes #1 = { sanitize_address }