Merge pull request #8090 from shajrawi/ConsumptionKind_UnconditionalCheckedCastValue

Add consumption kind to UnconditionalCheckedCastValueInst
This commit is contained in:
Joe Shajrawi
2017-03-14 15:30:26 -07:00
committed by GitHub
17 changed files with 80 additions and 36 deletions

View File

@@ -801,10 +801,12 @@ public:
}
UnconditionalCheckedCastValueInst *
createUnconditionalCheckedCastValue(SILLocation Loc, SILValue op,
SILType destTy) {
createUnconditionalCheckedCastValue(SILLocation Loc,
CastConsumptionKind consumption,
SILValue op, SILType destTy) {
return insert(UnconditionalCheckedCastValueInst::create(
getSILDebugLocation(Loc), op, destTy, F, OpenedArchetypes));
getSILDebugLocation(Loc), consumption, op, destTy, F,
OpenedArchetypes));
}
RetainValueInst *createRetainValue(SILLocation Loc, SILValue operand,

View File

@@ -1165,7 +1165,7 @@ void SILCloner<ImplClass>::visitUnconditionalCheckedCastValueInst(
SILType OpType = getOpType(Inst->getType());
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
doPostProcess(Inst, getBuilder().createUnconditionalCheckedCastValue(
OpLoc, OpValue, OpType));
OpLoc, Inst->getConsumptionKind(), OpValue, OpType));
}
template <typename ImplClass>

View File

@@ -2862,16 +2862,24 @@ class UnconditionalCheckedCastValueInst final
ValueKind::UnconditionalCheckedCastValueInst,
UnconditionalCheckedCastValueInst, ConversionInst, true> {
friend SILBuilder;
CastConsumptionKind ConsumptionKind;
UnconditionalCheckedCastValueInst(SILDebugLocation DebugLoc, SILValue Operand,
UnconditionalCheckedCastValueInst(SILDebugLocation DebugLoc,
CastConsumptionKind consumption,
SILValue Operand,
ArrayRef<SILValue> TypeDependentOperands,
SILType DestTy)
: UnaryInstructionWithTypeDependentOperandsBase(
DebugLoc, Operand, TypeDependentOperands, DestTy) {}
DebugLoc, Operand, TypeDependentOperands, DestTy),
ConsumptionKind(consumption) {}
static UnconditionalCheckedCastValueInst *
create(SILDebugLocation DebugLoc, SILValue Operand, SILType DestTy,
SILFunction &F, SILOpenedArchetypesState &OpenedArchetypes);
create(SILDebugLocation DebugLoc, CastConsumptionKind consumption,
SILValue Operand, SILType DestTy, SILFunction &F,
SILOpenedArchetypesState &OpenedArchetypes);
public:
CastConsumptionKind getConsumptionKind() const { return ConsumptionKind; }
};
/// StructInst - Represents a constructed loadable struct.