diff options
author | Yeting Kuo <46629943+yetingk@users.noreply.github.com> | 2024-06-04 11:40:33 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-04 11:40:33 +0800 |
commit | e9dd6b2a5332a2540849dc8366b00b17ab134c3f (patch) | |
tree | b4f66bea414ad0089edd5d0cb196f4f36e5ae3ac /llvm | |
parent | acfc79db3d2cda8417b8bfac6224ba74d0c2ece4 (diff) | |
download | llvm-e9dd6b2a5332a2540849dc8366b00b17ab134c3f.zip llvm-e9dd6b2a5332a2540849dc8366b00b17ab134c3f.tar.gz llvm-e9dd6b2a5332a2540849dc8366b00b17ab134c3f.tar.bz2 |
[Asan] Teach FunctionStackPoisoner to filter out struct type with scalable vector type. (#93406)
FunctionStackPoisoner does not serve for `AllocaInst` with scalable
vector type, but it does not filter out struct type with scalable vector
introduced by c8eb535aed0368c20b25fe05bca563ab38dd91e9.
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 6 | ||||
-rw-r--r-- | llvm/test/Instrumentation/AddressSanitizer/asan-struct-scalable.ll | 11 |
2 files changed, 15 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 9cc978d..18b98e9 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1139,8 +1139,10 @@ struct FunctionStackPoisoner : public InstVisitor<FunctionStackPoisoner> { /// Collect Alloca instructions we want (and can) handle. void visitAllocaInst(AllocaInst &AI) { // FIXME: Handle scalable vectors instead of ignoring them. - if (!ASan.isInterestingAlloca(AI) || - isa<ScalableVectorType>(AI.getAllocatedType())) { + const Type *AllocaType = AI.getAllocatedType(); + const auto *STy = dyn_cast<StructType>(AllocaType); + if (!ASan.isInterestingAlloca(AI) || isa<ScalableVectorType>(AllocaType) || + (STy && STy->containsHomogeneousScalableVectorTypes())) { if (AI.isStaticAlloca()) { // Skip over allocas that are present *before* the first instrumented // alloca, we don't want to move those around. diff --git a/llvm/test/Instrumentation/AddressSanitizer/asan-struct-scalable.ll b/llvm/test/Instrumentation/AddressSanitizer/asan-struct-scalable.ll new file mode 100644 index 0000000..d03f70d --- /dev/null +++ b/llvm/test/Instrumentation/AddressSanitizer/asan-struct-scalable.ll @@ -0,0 +1,11 @@ +; RUN: opt -passes=asan -disable-output -S %s +; Check not crash. + +define void @test() #0 { +entry: + %t0 = alloca { <vscale x 2 x i32>, <vscale x 2 x i32> }, align 4 + call void null(ptr null, ptr %t0, i64 0) + ret void +} + +attributes #0 = { sanitize_address } |