Skip to content

Commit dd95922

Browse files
committed
SILCombine: fix a problem in visitDifferentiableFunctionExtractInst
fixes a crash when trying to optimize ABI incompatible function types
1 parent 3211f68 commit dd95922

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,6 +2367,11 @@ SILCombiner::visitDifferentiableFunctionExtractInst(DifferentiableFunctionExtrac
23672367
// match the type of the original `differentiable_function_extract`,
23682368
// create a `convert_function`.
23692369
if (newValue->getType() != DFEI->getType()) {
2370+
CanSILFunctionType opTI = newValue->getType().castTo<SILFunctionType>();
2371+
CanSILFunctionType resTI = DFEI->getType().castTo<SILFunctionType>();
2372+
if (!opTI->isABICompatibleWith(resTI, *DFEI->getFunction()).isCompatible())
2373+
return nullptr;
2374+
23702375
std::tie(newValue, std::ignore) =
23712376
castValueToABICompatibleType(&Builder, DFEI->getLoc(),
23722377
newValue,

0 commit comments

Comments
 (0)