[llvm] e9dd6b2 - [Asan] Teach FunctionStackPoisoner to filter out struct type with scalable vector type. (#93406)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 3 20:40:37 PDT 2024
Author: Yeting Kuo
Date: 2024-06-04T11:40:33+08:00
New Revision: e9dd6b2a5332a2540849dc8366b00b17ab134c3f
URL: https://github.com/llvm/llvm-project/commit/e9dd6b2a5332a2540849dc8366b00b17ab134c3f
DIFF: https://github.com/llvm/llvm-project/commit/e9dd6b2a5332a2540849dc8366b00b17ab134c3f.diff
LOG: [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.
Added:
llvm/test/Instrumentation/AddressSanitizer/asan-struct-scalable.ll
Modified:
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 9cc978dc6c16e..18b98e9b8a67e 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 0000000000000..d03f70d808a53
--- /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 }
More information about the llvm-commits
mailing list