File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed
lib/SILOptimizer/Transforms Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -427,7 +427,8 @@ bool BridgedProperty::matchMethodCall(SILBasicBlock::iterator It) {
427427 SILValue Instance =
428428 FirstInst != ObjCMethod ? FirstInst : ObjCMethod->getOperand ();
429429 if (!ObjCMethod || !ObjCMethod->hasOneUse () ||
430- ObjCMethod->getOperand () != Instance)
430+ ObjCMethod->getOperand () != Instance ||
431+ ObjCMethod->getFunction ()->getLoweredFunctionType ()->isPolymorphic ())
431432 return false ;
432433
433434 // Don't outline in the outlined function.
@@ -568,7 +569,7 @@ bool BridgedProperty::matchInstSequence(SILBasicBlock::iterator It) {
568569 if (!Load) {
569570 // Try to match without the load/strong_retain prefix.
570571 auto *CMI = dyn_cast<ObjCMethodInst>(It);
571- if (!CMI)
572+ if (!CMI || CMI-> getFunction ()-> getLoweredFunctionType ()-> isPolymorphic () )
572573 return false ;
573574 FirstInst = CMI;
574575 } else
@@ -1104,7 +1105,8 @@ bool ObjCMethodCall::matchInstSequence(SILBasicBlock::iterator I) {
11041105 clearState ();
11051106
11061107 ObjCMethod = dyn_cast<ObjCMethodInst>(I);
1107- if (!ObjCMethod)
1108+ if (!ObjCMethod ||
1109+ ObjCMethod->getFunction ()->getLoweredFunctionType ()->isPolymorphic ())
11081110 return false ;
11091111 auto *Use = ObjCMethod->getSingleUse ();
11101112 if (!Use)
Original file line number Diff line number Diff line change 11#import < Foundation/Foundation.h>
22
3+ @protocol Proto
4+ - (id )requirement ;
5+ @end
6+
37@interface Gizmo : NSObject
48@property (nonatomic )NSString *stringProperty;
59- (NSString *) modifyString : (NSString *)str withNumber : (NSInteger ) num withFoobar : (id )foobar ;
610- (id ) doSomething : (NSArray <NSString*>*) arr ;
711@end
812
13+ @interface Gizmo2 <ObjectType: id<Proto>> : NSObject
14+ - (NSString *) doSomething ;
15+ @end
16+
917
Original file line number Diff line number Diff line change @@ -134,3 +134,9 @@ public func testOutlining() {
134134// CHECK: %7 = apply %2(%6, %1) : $@convention(objc_method) (Optional<NSArray>, Gizmo) -> @autoreleased Optional<AnyObject>
135135// CHECK: strong_release %4 : $NSArray
136136// CHECK: return %7 : $Optional<AnyObject>
137+
138+ public func dontCrash< T: Proto > ( x : Gizmo2 < T > ) {
139+ let s = x. doSomething ( )
140+ print ( s)
141+
142+ }
You can’t perform that action at this time.
0 commit comments