Skip to content

Commit 9e7687f

Browse files
authored
Merge pull request #13135 from gottesmm/pr-339c783b678f40183e3a6a3b4df5d136ad82f035
2 parents eaab1d0 + 2adcf4f commit 9e7687f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/SIL/SILInstructions.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,8 +2107,18 @@ ConvertFunctionInst::create(SILDebugLocation DebugLoc, SILValue Operand,
21072107
unsigned size =
21082108
totalSizeToAlloc<swift::Operand>(1 + TypeDependentOperands.size());
21092109
void *Buffer = Mod.allocateInst(size, alignof(ConvertFunctionInst));
2110-
return ::new (Buffer) ConvertFunctionInst(DebugLoc, Operand,
2111-
TypeDependentOperands, Ty);
2110+
auto *CFI = ::new (Buffer)
2111+
ConvertFunctionInst(DebugLoc, Operand, TypeDependentOperands, Ty);
2112+
// Make sure we are not performing ABI-incompatible conversions.
2113+
CanSILFunctionType opTI =
2114+
CFI->getOperand()->getType().castTo<SILFunctionType>();
2115+
(void)opTI;
2116+
CanSILFunctionType resTI =
2117+
CFI->getOperand()->getType().castTo<SILFunctionType>();
2118+
(void)resTI;
2119+
assert(opTI->isABICompatibleWith(resTI).isCompatible() &&
2120+
"Can not convert in between ABI incompatible function types");
2121+
return CFI;
21122122
}
21132123

21142124
bool KeyPathPatternComponent::isComputedSettablePropertyMutating() const {

0 commit comments

Comments
 (0)