Skip to content

Commit fa4c38b

Browse files
committed
[cast-opt] Now that all users of optimizeBridgedCasts use the SILDynamicCastInst entrypoint, delete the old entrypoint and inline its body into the new entrypoint.
1 parent e833d11 commit fa4c38b

File tree

2 files changed

+18
-28
lines changed

2 files changed

+18
-28
lines changed

include/swift/SILOptimizer/Utils/CastOptimizer.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,6 @@ class CastOptimizer {
147147
/// Check if it is a bridged cast and optimize it.
148148
///
149149
/// May change the control flow.
150-
SILInstruction *optimizeBridgedCasts(SILInstruction *Inst,
151-
CastConsumptionKind ConsumptionKind,
152-
bool isConditional, SILValue Src,
153-
SILValue Dest, CanType Source,
154-
CanType Target, SILBasicBlock *SuccessBB,
155-
SILBasicBlock *FailureBB);
156-
157150
SILInstruction *optimizeBridgedCasts(SILDynamicCastInst cast);
158151

159152
SILValue optimizeMetatypeConversion(ConversionInst *mci,

lib/SILOptimizer/Utils/CastOptimizer.cpp

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -596,28 +596,25 @@ SILInstruction *CastOptimizer::optimizeBridgedSwiftToObjCCast(
596596
return NewI;
597597
}
598598

599-
SILInstruction *CastOptimizer::optimizeBridgedCasts(SILDynamicCastInst cast) {
600-
return optimizeBridgedCasts(
601-
cast.getInstruction(), cast.getBridgedConsumptionKind(),
602-
cast.isConditional(), cast.getSource(), cast.getDest(),
603-
cast.getSourceType(), cast.getTargetType(), cast.getSuccessBlock(),
604-
cast.getFailureBlock());
605-
}
606-
607-
/// Make use of the fact that some of these casts cannot fail.
608-
/// For example, if the ObjC type is exactly the expected
609-
/// _ObjectiveCType type, then it would always succeed for
610-
/// NSString, NSNumber, etc.
611-
/// Casts from NSArray, NSDictionary and NSSet may fail.
599+
/// Make use of the fact that some of these casts cannot fail. For example, if
600+
/// the ObjC type is exactly the expected _ObjectiveCType type, then it would
601+
/// always succeed for NSString, NSNumber, etc. Casts from NSArray,
602+
/// NSDictionary and NSSet may fail.
612603
///
613-
/// If ObjC class is not exactly _ObjectiveCType, then
614-
/// its conversion to a required _ObjectiveCType may fail.
615-
SILInstruction *CastOptimizer::optimizeBridgedCasts(
616-
SILInstruction *Inst, CastConsumptionKind ConsumptionKind,
617-
bool isConditional, SILValue Src, SILValue Dest, CanType source,
618-
CanType target, SILBasicBlock *SuccessBB, SILBasicBlock *FailureBB) {
619-
620-
auto &M = Inst->getModule();
604+
/// If ObjC class is not exactly _ObjectiveCType, then its conversion to a
605+
/// required _ObjectiveCType may fail.
606+
SILInstruction *
607+
CastOptimizer::optimizeBridgedCasts(SILDynamicCastInst dynamicCast) {
608+
SILInstruction *Inst = dynamicCast.getInstruction();
609+
CastConsumptionKind ConsumptionKind = dynamicCast.getBridgedConsumptionKind();
610+
bool isConditional = dynamicCast.isConditional();
611+
SILValue Src = dynamicCast.getSource();
612+
SILValue Dest = dynamicCast.getDest();
613+
CanType source = dynamicCast.getSourceType();
614+
CanType target = dynamicCast.getTargetType();
615+
SILBasicBlock *SuccessBB = dynamicCast.getSuccessBlock();
616+
SILBasicBlock *FailureBB = dynamicCast.getFailureBlock();
617+
auto &M = dynamicCast.getModule();
621618

622619
// To apply the bridged optimizations, we should ensure that types are not
623620
// existential (and keep in mind that generic parameters can be existentials),

0 commit comments

Comments
 (0)