Skip to content

Commit 7708e25

Browse files
authored
Merge pull request #21710 from aschwaighofer/outliner_fix_open_existential
2 parents 15aaa1e + 50cac1d commit 7708e25

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

lib/SILOptimizer/Transforms/Outliner.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,8 @@ bool BridgedProperty::matchMethodCall(SILBasicBlock::iterator It) {
554554
if (!ObjCMethod || !ObjCMethod->hasOneUse() ||
555555
ObjCMethod->getOperand() != Instance ||
556556
ObjCMethod->getFunction()->getLoweredFunctionType()->isPolymorphic() ||
557-
ObjCMethod->getType().castTo<SILFunctionType>()->isPolymorphic())
557+
ObjCMethod->getType().castTo<SILFunctionType>()->isPolymorphic() ||
558+
ObjCMethod->getType().castTo<SILFunctionType>()->hasOpenedExistential())
558559
return false;
559560

560561
// Don't outline in the outlined function.
@@ -608,7 +609,8 @@ bool BridgedProperty::matchInstSequence(SILBasicBlock::iterator It) {
608609
// Try to match without the load/strong_retain prefix.
609610
auto *CMI = dyn_cast<ObjCMethodInst>(It);
610611
if (!CMI || CMI->getFunction()->getLoweredFunctionType()->isPolymorphic() ||
611-
CMI->getType().castTo<SILFunctionType>()->isPolymorphic())
612+
CMI->getType().castTo<SILFunctionType>()->isPolymorphic() ||
613+
CMI->getType().castTo<SILFunctionType>()->hasOpenedExistential())
612614
return false;
613615
FirstInst = CMI;
614616
} else
@@ -1039,7 +1041,8 @@ bool ObjCMethodCall::matchInstSequence(SILBasicBlock::iterator I) {
10391041
ObjCMethod = dyn_cast<ObjCMethodInst>(I);
10401042
if (!ObjCMethod ||
10411043
ObjCMethod->getFunction()->getLoweredFunctionType()->isPolymorphic() ||
1042-
ObjCMethod->getType().castTo<SILFunctionType>()->isPolymorphic())
1044+
ObjCMethod->getType().castTo<SILFunctionType>()->isPolymorphic() ||
1045+
ObjCMethod->getType().castTo<SILFunctionType>()->hasOpenedExistential())
10431046
return false;
10441047

10451048
auto *Use = ObjCMethod->getSingleUse();

test/SILOptimizer/Inputs/Outliner.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@
2222
- (NSString*) doSomething;
2323
- (id) doSomething2 : (NSArray<NSString*>*) arr;
2424
@end
25+
26+
NS_ASSUME_NONNULL_BEGIN
27+
@protocol Treeish <NSObject>
28+
- (nullable NSArray *) treeishChildren;
29+
@end
30+
NS_ASSUME_NONNULL_END

test/SILOptimizer/outliner.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,6 @@ extension Operation {
175175
}
176176
}
177177

178+
public func dontCrash(a: Any) {
179+
(a as AnyObject).treeishChildren()
180+
}

0 commit comments

Comments
 (0)