Skip to content

Commit 6ba9bff

Browse files
committed
[StackNesting] Handle stackAlloc builtins.
Both stackAlloc and unprotectedStackAlloc are paired with stackDealloc builtins.
1 parent 1238b0e commit 6ba9bff

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/SILOptimizer/Utils/StackNesting.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,17 @@ static SILInstruction *createDealloc(SILInstruction *Alloc,
196196
return B.createDeallocStackRef(Location, cast<AllocRefInstBase>(Alloc));
197197
case SILInstructionKind::AllocPackInst:
198198
return B.createDeallocPack(Location, cast<AllocPackInst>(Alloc));
199+
case SILInstructionKind::BuiltinInst: {
200+
auto *bi = cast<BuiltinInst>(Alloc);
201+
assert(bi->getBuiltinKind() == BuiltinValueKind::StackAlloc ||
202+
bi->getBuiltinKind() == BuiltinValueKind::UnprotectedStackAlloc);
203+
auto &context = Alloc->getFunction()->getModule().getASTContext();
204+
auto identifier =
205+
context.getIdentifier(getBuiltinName(BuiltinValueKind::StackDealloc));
206+
return B.createBuiltin(Location, identifier,
207+
SILType::getEmptyTupleType(context),
208+
SubstitutionMap(), {bi});
209+
}
199210
default:
200211
llvm_unreachable("unknown stack allocation");
201212
}

0 commit comments

Comments
 (0)