Skip to content

[sil] Catch if we are creating ABI incompatible convert_function inst… #13135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/SIL/SILInstructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2107,8 +2107,18 @@ ConvertFunctionInst::create(SILDebugLocation DebugLoc, SILValue Operand,
unsigned size =
totalSizeToAlloc<swift::Operand>(1 + TypeDependentOperands.size());
void *Buffer = Mod.allocateInst(size, alignof(ConvertFunctionInst));
return ::new (Buffer) ConvertFunctionInst(DebugLoc, Operand,
TypeDependentOperands, Ty);
auto *CFI = ::new (Buffer)
ConvertFunctionInst(DebugLoc, Operand, TypeDependentOperands, Ty);
// Make sure we are not performing ABI-incompatible conversions.
CanSILFunctionType opTI =
CFI->getOperand()->getType().castTo<SILFunctionType>();
(void)opTI;
CanSILFunctionType resTI =
CFI->getOperand()->getType().castTo<SILFunctionType>();
(void)resTI;
assert(opTI->isABICompatibleWith(resTI).isCompatible() &&
"Can not convert in between ABI incompatible function types");
return CFI;
}

bool KeyPathPatternComponent::isComputedSettablePropertyMutating() const {
Expand Down