mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[sil] Add a forwarding cast called unchecked_value_cast.
Today unchecked_bitwise_cast returns a value with ObjCUnowned ownership. This is important to do since the instruction can truncate memory meaning we want to treat it as a new object that must be copied before use. This means that in OSSA we do not have a purely ossa forwarding unchecked layout-compatible assuming cast. This role is filled by unchecked_value_cast.
This commit is contained in:
@@ -2217,6 +2217,21 @@ UncheckedRefCastInst::create(SILDebugLocation DebugLoc, SILValue Operand,
|
||||
TypeDependentOperands, Ty);
|
||||
}
|
||||
|
||||
UncheckedValueCastInst *
|
||||
UncheckedValueCastInst::create(SILDebugLocation DebugLoc, SILValue Operand,
|
||||
SILType Ty, SILFunction &F,
|
||||
SILOpenedArchetypesState &OpenedArchetypes) {
|
||||
SILModule &Mod = F.getModule();
|
||||
SmallVector<SILValue, 8> TypeDependentOperands;
|
||||
collectTypeDependentOperands(TypeDependentOperands, OpenedArchetypes, F,
|
||||
Ty.getASTType());
|
||||
unsigned size =
|
||||
totalSizeToAlloc<swift::Operand>(1 + TypeDependentOperands.size());
|
||||
void *Buffer = Mod.allocateInst(size, alignof(UncheckedValueCastInst));
|
||||
return ::new (Buffer)
|
||||
UncheckedValueCastInst(DebugLoc, Operand, TypeDependentOperands, Ty);
|
||||
}
|
||||
|
||||
UncheckedAddrCastInst *
|
||||
UncheckedAddrCastInst::create(SILDebugLocation DebugLoc, SILValue Operand,
|
||||
SILType Ty, SILFunction &F,
|
||||
|
||||
Reference in New Issue
Block a user