@@ -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
@@ -8642,6 +8667,27 @@ class DeallocPackInst :
86428667 : UnaryInstructionBase(debugLoc, operand) {}
86438668};
86448669
8670+ // / DeallocPackMetadataInst - Deallocate stack memory allocated on behalf of the
8671+ // / operand by IRGen.
8672+ // /
8673+ // / Only valid in lowered SIL.
8674+ class DeallocPackMetadataInst final
8675+ : public UnaryInstructionBase<SILInstructionKind::DeallocPackMetadataInst,
8676+ DeallocationInst> {
8677+ friend SILBuilder;
8678+
8679+ DeallocPackMetadataInst (SILDebugLocation debugLoc, SILValue alloc)
8680+ : UnaryInstructionBase(debugLoc, alloc) {}
8681+
8682+ public:
8683+ AllocPackMetadataInst *getAllocation () {
8684+ return cast<AllocPackMetadataInst>(getOperand ().getDefiningInstruction ());
8685+ }
8686+ // / The instruction which may trigger on-stack pack metadata when IRGen
8687+ // / lowering.
8688+ SILInstruction *getIntroducer () { return getAllocation ()->getIntroducer (); }
8689+ };
8690+
86458691// / Like DeallocStackInst, but for `alloc_ref [stack]`.
86468692class DeallocStackRefInst
86478693 : public UnaryInstructionBase<SILInstructionKind::DeallocStackRefInst,
0 commit comments