Skip to content

Commit 129e4a7

Browse files
author
Yeting Kuo
committed
[Asan] Teach FunctionStackPoisoner to filter out struct type with sclable vector type.
FunctionStackPoisoner does not serve for AllocaInst with scalable vector type, but it does not filter out struct type with scalable vector introduced by c8eb535. Currently, llvm does not allows an element of a struct type with scalable vector is an element of a struct type vector, so we only need to check the first layer of the struct type of AllocaInst.
1 parent 7c265e9 commit 129e4a7

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,8 +1139,16 @@ struct FunctionStackPoisoner : public InstVisitor<FunctionStackPoisoner> {
11391139
/// Collect Alloca instructions we want (and can) handle.
11401140
void visitAllocaInst(AllocaInst &AI) {
11411141
// FIXME: Handle scalable vectors instead of ignoring them.
1142+
auto IsScalableVecTy = [](const Type *Ty) {
1143+
if (const auto *STy = dyn_cast<StructType>(Ty))
1144+
return any_of(STy->elements(), [](const Type *ElemTy) {
1145+
return isa<ScalableVectorType>(ElemTy);
1146+
});
1147+
return isa<ScalableVectorType>(Ty);
1148+
};
1149+
11421150
if (!ASan.isInterestingAlloca(AI) ||
1143-
isa<ScalableVectorType>(AI.getAllocatedType())) {
1151+
IsScalableVecTy(AI.getAllocatedType())) {
11441152
if (AI.isStaticAlloca()) {
11451153
// Skip over allocas that are present *before* the first instrumented
11461154
// alloca, we don't want to move those around.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; RUN: opt -passes=asan -disable-output -S %s
2+
; Check not crash.
3+
4+
define void @test() #0 {
5+
entry:
6+
%t0 = alloca { <vscale x 2 x i32>, <vscale x 2 x i32> }, align 4
7+
call void null(ptr null, ptr %t0, i64 0)
8+
ret void
9+
}
10+
11+
attributes #0 = { sanitize_address }

0 commit comments

Comments
 (0)