[SIL] Add dead_end flag to destroy_value.

This commit is contained in:
Nate Chandler
2024-07-01 17:51:11 -07:00
parent 91fe12aab4
commit a8cc3bfdda
15 changed files with 200 additions and 21 deletions

View File

@@ -1442,16 +1442,16 @@ public:
ExplicitCopyValueInst(getSILDebugLocation(Loc), operand));
}
DestroyValueInst *
createDestroyValue(SILLocation Loc, SILValue operand,
PoisonRefs_t poisonRefs = DontPoisonRefs) {
DestroyValueInst *createDestroyValue(SILLocation Loc, SILValue operand,
PoisonRefs_t poisonRefs = DontPoisonRefs,
IsDeadEnd_t isDeadEnd = IsntDeadEnd) {
assert(getFunction().hasOwnership());
assert(isLoadableOrOpaque(operand->getType()));
assert(!operand->getType().isTrivial(getFunction()) &&
"Should not be passing trivial values to this api. Use instead "
"emitDestroyValueOperation");
return insert(new (getModule()) DestroyValueInst(getSILDebugLocation(Loc),
operand, poisonRefs));
return insert(new (getModule()) DestroyValueInst(
getSILDebugLocation(Loc), operand, poisonRefs, isDeadEnd));
}
MoveValueInst *createMoveValue(

View File

@@ -2208,10 +2208,10 @@ void SILCloner<ImplClass>::visitDestroyValueInst(DestroyValueInst *Inst) {
RefCountingInst::Atomicity::Atomic));
}
recordClonedInstruction(
Inst, getBuilder().createDestroyValue(getOpLocation(Inst->getLoc()),
getOpValue(Inst->getOperand()),
Inst->poisonRefs()));
recordClonedInstruction(Inst, getBuilder().createDestroyValue(
getOpLocation(Inst->getLoc()),
getOpValue(Inst->getOperand()),
Inst->poisonRefs(), Inst->isDeadEnd()));
}
template <typename ImplClass>

View File

@@ -8806,6 +8806,11 @@ class UnownedCopyValueInst
};
#include "swift/AST/ReferenceStorage.def"
enum IsDeadEnd_t : bool {
IsntDeadEnd = false,
IsDeadEnd = true,
};
class DestroyValueInst
: public UnaryInstructionBase<SILInstructionKind::DestroyValueInst,
NonValueInstruction> {
@@ -8813,9 +8818,10 @@ class DestroyValueInst
USE_SHARED_UINT8;
DestroyValueInst(SILDebugLocation DebugLoc, SILValue operand,
PoisonRefs_t poisonRefs)
PoisonRefs_t poisonRefs, IsDeadEnd_t isDeadEnd)
: UnaryInstructionBase(DebugLoc, operand) {
setPoisonRefs(poisonRefs);
sharedUInt8().DestroyValueInst.poisonRefs = poisonRefs;
sharedUInt8().DestroyValueInst.deadEnd = isDeadEnd;
}
public:
@@ -8843,6 +8849,10 @@ public:
/// If the value being destroyed is a stack allocation of a nonescaping
/// closure, then return the PartialApplyInst that allocated the closure.
PartialApplyInst *getNonescapingClosureAllocation() const;
IsDeadEnd_t isDeadEnd() const {
return IsDeadEnd_t(sharedUInt8().DestroyValueInst.deadEnd);
}
};
class MoveValueInst

View File

@@ -205,7 +205,9 @@ protected:
SHARED_FIELD(AddressToPointerInst, bool needsStackProtection);
SHARED_FIELD(IndexAddrInst, bool needsStackProtection);
SHARED_FIELD(HopToExecutorInst, bool mandatory);
SHARED_FIELD(DestroyValueInst, bool poisonRefs);
SHARED_FIELD(DestroyValueInst, uint8_t
poisonRefs : 1,
deadEnd : 1);
SHARED_FIELD(EndCOWMutationInst, bool keepUnique);
SHARED_FIELD(ConvertFunctionInst, bool withoutActuallyEscaping);
SHARED_FIELD(BeginCOWMutationInst, bool native);