@@ -821,6 +821,10 @@ class SILInstruction : public llvm::ilist_node<SILInstruction> {
821821 // / The first operand must be the allocating instruction.
822822 bool isDeallocatingStack () const ;
823823
824+ // / Whether IRGen lowering of this instruction may result in emitting packs of
825+ // / metadata or witness tables.
826+ bool mayRequirePackMetadata () const ;
827+
824828 // / Create a new copy of this instruction, which retains all of the operands
825829 // / and other information of this one. If an insertion point is specified,
826830 // / then the new instruction is inserted before the specified point, otherwise
@@ -2275,6 +2279,27 @@ class AllocPackInst final
22752279 }
22762280};
22772281
2282+ // / AllocPackMetadataInst - Marker instruction indicating that the next
2283+ // / instruction might allocate on-stack pack metadata
2284+ // / during IRGen.
2285+ // /
2286+ // / Only valid in lowered SIL.
2287+ class AllocPackMetadataInst final
2288+ : public NullaryInstructionWithTypeDependentOperandsBase<
2289+ SILInstructionKind::AllocPackMetadataInst, AllocPackMetadataInst,
2290+ AllocationInst> {
2291+ friend SILBuilder;
2292+
2293+ AllocPackMetadataInst (SILDebugLocation loc, SILType elementType)
2294+ : NullaryInstructionWithTypeDependentOperandsBase(
2295+ loc, {}, elementType.getAddressType()) {}
2296+
2297+ public:
2298+ // / The instruction which may trigger on-stack pack metadata when IRGen
2299+ // / lowering.
2300+ SILInstruction *getIntroducer () { return getNextInstruction (); }
2301+ };
2302+
22782303// / The base class for AllocRefInst and AllocRefDynamicInst.
22792304// /
22802305// / The first NumTailTypes operands are counts for the tail allocated
@@ -8685,6 +8710,27 @@ class DeallocPackInst :
86858710 : UnaryInstructionBase(debugLoc, operand) {}
86868711};
86878712
8713+ // / DeallocPackMetadataInst - Deallocate stack memory allocated on behalf of the
8714+ // / operand by IRGen.
8715+ // /
8716+ // / Only valid in lowered SIL.
8717+ class DeallocPackMetadataInst final
8718+ : public UnaryInstructionBase<SILInstructionKind::DeallocPackMetadataInst,
8719+ DeallocationInst> {
8720+ friend SILBuilder;
8721+
8722+ DeallocPackMetadataInst (SILDebugLocation debugLoc, SILValue alloc)
8723+ : UnaryInstructionBase(debugLoc, alloc) {}
8724+
8725+ public:
8726+ AllocPackMetadataInst *getAllocation () {
8727+ return cast<AllocPackMetadataInst>(getOperand ().getDefiningInstruction ());
8728+ }
8729+ // / The instruction which may trigger on-stack pack metadata when IRGen
8730+ // / lowering.
8731+ SILInstruction *getIntroducer () { return getAllocation ()->getIntroducer (); }
8732+ };
8733+
86888734// / Like DeallocStackInst, but for `alloc_ref [stack]`.
86898735class DeallocStackRefInst
86908736 : public UnaryInstructionBase<SILInstructionKind::DeallocStackRefInst,
0 commit comments