Skip to content

Commit 0c6b175

Browse files
authored
Merge pull request #24018 from gottesmm/pr-d15164f257213e702017277be57d6b32873d8f19
2 parents dae03ab + 9caeaaf commit 0c6b175

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/SILOptimizer/Utils/CastOptimizer.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545

4646
using namespace swift;
4747

48+
//===----------------------------------------------------------------------===//
49+
// ObjC -> Swift Bridging Cast Optimization
50+
//===----------------------------------------------------------------------===//
51+
4852
static SILFunction *
4953
getObjCToSwiftBridgingFunction(SILOptFunctionBuilder &funcBuilder,
5054
SILDynamicCastInst dynamicCast) {
@@ -358,6 +362,10 @@ CastOptimizer::optimizeBridgedObjCToSwiftCast(SILDynamicCastInst dynamicCast) {
358362
return (newI) ? newI : AI;
359363
}
360364

365+
//===----------------------------------------------------------------------===//
366+
// Swift -> ObjC Bridging Cast Optimization
367+
//===----------------------------------------------------------------------===//
368+
361369
static bool canOptimizeCast(const swift::Type &BridgedTargetTy,
362370
swift::SILModule &M,
363371
swift::SILFunctionConventions &substConv) {
@@ -702,6 +710,10 @@ CastOptimizer::optimizeBridgedSwiftToObjCCast(SILDynamicCastInst dynamicCast) {
702710
return NewI;
703711
}
704712

713+
//===----------------------------------------------------------------------===//
714+
// Top Level Bridge Cast Optimization Entrypoint
715+
//===----------------------------------------------------------------------===//
716+
705717
/// Make use of the fact that some of these casts cannot fail. For
706718
/// example, if the ObjC type is exactly the expected _ObjectiveCType
707719
/// type, then it would always succeed for NSString, NSNumber, etc.
@@ -768,6 +780,10 @@ CastOptimizer::optimizeBridgedCasts(SILDynamicCastInst dynamicCast) {
768780
llvm_unreachable("Unknown kind of bridging");
769781
}
770782

783+
//===----------------------------------------------------------------------===//
784+
// Cast Optimizer Public API
785+
//===----------------------------------------------------------------------===//
786+
771787
SILInstruction *CastOptimizer::simplifyCheckedCastAddrBranchInst(
772788
CheckedCastAddrBranchInst *Inst) {
773789
if (auto *I = optimizeCheckedCastAddrBranchInst(Inst))

0 commit comments

Comments
 (0)