diff --git a/lib/SILOptimizer/Transforms/Outliner.cpp b/lib/SILOptimizer/Transforms/Outliner.cpp index ac51644ac87..69c43383cba 100644 --- a/lib/SILOptimizer/Transforms/Outliner.cpp +++ b/lib/SILOptimizer/Transforms/Outliner.cpp @@ -492,7 +492,8 @@ static bool matchSwitch(SwitchInfo &SI, SILInstruction *Inst, auto *BridgeFun = FunRef->getInitiallyReferencedFunction(); auto *SwiftModule = BridgeFun->getModule().getSwiftModule(); auto bridgeWitness = getBridgeFromObjectiveC(NativeType, SwiftModule); - if (BridgeFun->getName() != bridgeWitness.mangle()) + if (bridgeWitness == SILDeclRef() || + BridgeFun->getName() != bridgeWitness.mangle()) return false; // %41 = enum $Optional, #Optional.some!enumelt.1, %40 : $String @@ -809,7 +810,8 @@ BridgedArgument BridgedArgument::match(unsigned ArgIdx, SILValue Arg, auto *BridgeFun = FunRef->getInitiallyReferencedFunction(); auto *SwiftModule = BridgeFun->getModule().getSwiftModule(); auto bridgeWitness = getBridgeToObjectiveC(NativeType, SwiftModule); - if (BridgeFun->getName() != bridgeWitness.mangle()) + if (bridgeWitness == SILDeclRef() || + BridgeFun->getName() != bridgeWitness.mangle()) return BridgedArgument(); return BridgedArgument(ArgIdx, FunRef, BridgeCall, Enum, BridgedValueRelease, diff --git a/test/SILOptimizer/Inputs/Outliner.h b/test/SILOptimizer/Inputs/Outliner.h index e08479f6688..6c41c2920e3 100644 --- a/test/SILOptimizer/Inputs/Outliner.h +++ b/test/SILOptimizer/Inputs/Outliner.h @@ -34,6 +34,7 @@ typedef NS_ENUM(NSUInteger, MyEventType) { @interface MyView : NSObject @property (nonatomic, nullable, readonly, strong) MyWindow *window; +@property (nonatomic, nullable, strong) MyWindow *window2; @end typedef struct MyPoint { diff --git a/test/SILOptimizer/outliner.swift b/test/SILOptimizer/outliner.swift index c71d166911a..1c022811f8d 100644 --- a/test/SILOptimizer/outliner.swift +++ b/test/SILOptimizer/outliner.swift @@ -222,3 +222,20 @@ public func testCalendar() { let formatter = DateFormatter() formatter.calendar = Calendar(identifier: .gregorian) } + +open class Test +{ + @inline(never) + public func getWindow() -> MyWindow + { + return MyWindow() + } + + public func testDontCrash() -> MyView + { + + let view = MyView() + view.window2 = getWindow() + return view + } +}