Skip to content

Commit 7a91af8

Browse files
committed
Revert "[sil-combine] Extend optimizeApplyOfConvertFunctionInst to work with try_apply."
This reverts commit r30868 because it (possibly in combination with r30871) break these tests: Swift :: 1_stdlib/ExistentialCollection.swift Swift :: Prototypes/CollectionTransformers.swift Swift SVN r30904
1 parent 7c05776 commit 7a91af8

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

lib/SILPasses/SILCombiner.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ class SILCombiner :
267267

268268
SILInstruction *tryOptimizeApplyOfPartialApply(PartialApplyInst *PAI);
269269

270-
SILInstruction *optimizeApplyOfConvertFunctionInst(FullApplySite AI,
270+
SILInstruction *optimizeApplyOfConvertFunctionInst(ApplyInst *AI,
271271
ConvertFunctionInst *CFI);
272272
// Optimize concatenation of string literals.
273273
// Constant-fold concatenation of string literals known at compile-time.

lib/SILPasses/SILCombinerVisitors.cpp

+10-17
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ SILInstruction *SILCombiner::optimizeBuiltinCompareEq(BuiltinInst *BI,
932932
}
933933

934934
SILInstruction *
935-
SILCombiner::optimizeApplyOfConvertFunctionInst(FullApplySite AI,
935+
SILCombiner::optimizeApplyOfConvertFunctionInst(ApplyInst *AI,
936936
ConvertFunctionInst *CFI) {
937937
// We only handle simplification of static function references. If we don't
938938
// have one, bail.
@@ -941,7 +941,7 @@ SILCombiner::optimizeApplyOfConvertFunctionInst(FullApplySite AI,
941941
return nullptr;
942942

943943
// Grab our relevant callee types...
944-
CanSILFunctionType SubstCalleeTy = AI.getSubstCalleeType();
944+
CanSILFunctionType SubstCalleeTy = AI->getSubstCalleeType();
945945
auto ConvertCalleeTy =
946946
CFI->getOperand().getType().castTo<SILFunctionType>();
947947

@@ -951,7 +951,7 @@ SILCombiner::optimizeApplyOfConvertFunctionInst(FullApplySite AI,
951951

952952
// Ok, we can now perform our transformation. Grab AI's operands and the
953953
// relevant types from the ConvertFunction function type and AI.
954-
OperandValueArrayRef Ops = AI.getArgumentsWithoutIndirectResult();
954+
OperandValueArrayRef Ops = AI->getArgumentsWithoutIndirectResult();
955955
auto OldOpTypes = SubstCalleeTy->getParameterSILTypes();
956956
auto NewOpTypes = ConvertCalleeTy->getParameterSILTypes();
957957

@@ -970,14 +970,14 @@ SILCombiner::optimizeApplyOfConvertFunctionInst(FullApplySite AI,
970970
// other types alone.
971971
if (OldOpType.isAddress()) {
972972
assert(NewOpType.isAddress() && "Addresses should map to addresses.");
973-
auto UAC = Builder->createUncheckedAddrCast(AI.getLoc(), Op, NewOpType);
974-
UAC->setDebugScope(AI.getDebugScope());
973+
auto UAC = Builder->createUncheckedAddrCast(AI->getLoc(), Op, NewOpType);
974+
UAC->setDebugScope(AI->getDebugScope());
975975
Args.push_back(UAC);
976976
} else if (OldOpType.isHeapObjectReferenceType()) {
977977
assert(NewOpType.isHeapObjectReferenceType() &&
978978
"refs should map to refs.");
979-
auto URC = Builder->createUncheckedRefCast(AI.getLoc(), Op, NewOpType);
980-
URC->setDebugScope(AI.getDebugScope());
979+
auto URC = Builder->createUncheckedRefCast(AI->getLoc(), Op, NewOpType);
980+
URC->setDebugScope(AI->getDebugScope());
981981
Args.push_back(URC);
982982
} else {
983983
Args.push_back(Op);
@@ -986,18 +986,11 @@ SILCombiner::optimizeApplyOfConvertFunctionInst(FullApplySite AI,
986986

987987
SILType CCSILTy = SILType::getPrimitiveObjectType(ConvertCalleeTy);
988988
// Create the new apply inst.
989-
SILInstruction *NAI;
990-
if (auto *TAI = dyn_cast<TryApplyInst>(AI))
991-
NAI = TryApplyInst::create(AI.getLoc(), FRI, CCSILTy,
989+
auto NAI = ApplyInst::create(AI->getLoc(), FRI, CCSILTy,
990+
ConvertCalleeTy->getSILResult(),
992991
ArrayRef<Substitution>(), Args,
993-
TAI->getNormalBB(), TAI->getErrorBB(),
994992
*FRI->getReferencedFunction());
995-
else
996-
NAI = ApplyInst::create(AI.getLoc(), FRI, CCSILTy,
997-
ConvertCalleeTy->getSILResult(),
998-
ArrayRef<Substitution>(), Args,
999-
*FRI->getReferencedFunction());
1000-
NAI->setDebugScope(AI.getDebugScope());
993+
NAI->setDebugScope(AI->getDebugScope());
1001994
return NAI;
1002995
}
1003996

0 commit comments

Comments
 (0)