Skip to content

Commit d75ca9a

Browse files
committed
When checking for ABI compatibility of a convert_function, don't compare the operand against itself, compare the operand against the convert_function result.
This was a thinko on my part. rdar://34222540
1 parent 6fb2ad1 commit d75ca9a

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

lib/SIL/SILInstructions.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,15 +2108,21 @@ ConvertFunctionInst::create(SILDebugLocation DebugLoc, SILValue Operand,
21082108
void *Buffer = Mod.allocateInst(size, alignof(ConvertFunctionInst));
21092109
auto *CFI = ::new (Buffer)
21102110
ConvertFunctionInst(DebugLoc, Operand, TypeDependentOperands, Ty);
2111-
// Make sure we are not performing ABI-incompatible conversions.
2112-
CanSILFunctionType opTI =
2113-
CFI->getOperand()->getType().castTo<SILFunctionType>();
2114-
(void)opTI;
2115-
CanSILFunctionType resTI =
2116-
CFI->getOperand()->getType().castTo<SILFunctionType>();
2117-
(void)resTI;
2118-
assert(opTI->isABICompatibleWith(resTI).isCompatible() &&
2119-
"Can not convert in between ABI incompatible function types");
2111+
// If we do not have lowered SIL, make sure that are not performing
2112+
// ABI-incompatible conversions.
2113+
//
2114+
// *NOTE* We purposely do not use an early return here to ensure that in
2115+
// builds without assertions this whole if statement is optimized out.
2116+
if (F.getModule().getStage() != SILStage::Lowered) {
2117+
// Make sure we are not performing ABI-incompatible conversions.
2118+
CanSILFunctionType opTI =
2119+
CFI->getOperand()->getType().castTo<SILFunctionType>();
2120+
(void)opTI;
2121+
CanSILFunctionType resTI = CFI->getType().castTo<SILFunctionType>();
2122+
(void)resTI;
2123+
assert(opTI->isABICompatibleWith(resTI).isCompatible() &&
2124+
"Can not convert in between ABI incompatible function types");
2125+
}
21202126
return CFI;
21212127
}
21222128

0 commit comments

Comments
 (0)