Skip to content

[sil] When checking for ABI compatibility of a convert_function, don'… #13283

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
24 changes: 15 additions & 9 deletions lib/SIL/SILInstructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2108,15 +2108,21 @@ ConvertFunctionInst::create(SILDebugLocation DebugLoc, SILValue Operand,
void *Buffer = Mod.allocateInst(size, alignof(ConvertFunctionInst));
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");
// If we do not have lowered SIL, make sure that are not performing
// ABI-incompatible conversions.
//
// *NOTE* We purposely do not use an early return here to ensure that in
// builds without assertions this whole if statement is optimized out.
if (F.getModule().getStage() != SILStage::Lowered) {
// Make sure we are not performing ABI-incompatible conversions.
CanSILFunctionType opTI =
CFI->getOperand()->getType().castTo<SILFunctionType>();
(void)opTI;
CanSILFunctionType resTI = CFI->getType().castTo<SILFunctionType>();
(void)resTI;
assert(opTI->isABICompatibleWith(resTI).isCompatible() &&
"Can not convert in between ABI incompatible function types");
}
return CFI;
}

Expand Down