Skip to content

Outliner: We don't support calls with opened existentials #21710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/SILOptimizer/Transforms/Outliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,8 @@ bool BridgedProperty::matchMethodCall(SILBasicBlock::iterator It) {
if (!ObjCMethod || !ObjCMethod->hasOneUse() ||
ObjCMethod->getOperand() != Instance ||
ObjCMethod->getFunction()->getLoweredFunctionType()->isPolymorphic() ||
ObjCMethod->getType().castTo<SILFunctionType>()->isPolymorphic())
ObjCMethod->getType().castTo<SILFunctionType>()->isPolymorphic() ||
ObjCMethod->getType().castTo<SILFunctionType>()->hasOpenedExistential())
return false;

// Don't outline in the outlined function.
Expand Down Expand Up @@ -608,7 +609,8 @@ bool BridgedProperty::matchInstSequence(SILBasicBlock::iterator It) {
// Try to match without the load/strong_retain prefix.
auto *CMI = dyn_cast<ObjCMethodInst>(It);
if (!CMI || CMI->getFunction()->getLoweredFunctionType()->isPolymorphic() ||
CMI->getType().castTo<SILFunctionType>()->isPolymorphic())
CMI->getType().castTo<SILFunctionType>()->isPolymorphic() ||
CMI->getType().castTo<SILFunctionType>()->hasOpenedExistential())
return false;
FirstInst = CMI;
} else
Expand Down Expand Up @@ -1039,7 +1041,8 @@ bool ObjCMethodCall::matchInstSequence(SILBasicBlock::iterator I) {
ObjCMethod = dyn_cast<ObjCMethodInst>(I);
if (!ObjCMethod ||
ObjCMethod->getFunction()->getLoweredFunctionType()->isPolymorphic() ||
ObjCMethod->getType().castTo<SILFunctionType>()->isPolymorphic())
ObjCMethod->getType().castTo<SILFunctionType>()->isPolymorphic() ||
ObjCMethod->getType().castTo<SILFunctionType>()->hasOpenedExistential())
return false;

auto *Use = ObjCMethod->getSingleUse();
Expand Down
6 changes: 6 additions & 0 deletions test/SILOptimizer/Inputs/Outliner.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@
- (NSString*) doSomething;
- (id) doSomething2 : (NSArray<NSString*>*) arr;
@end

NS_ASSUME_NONNULL_BEGIN
@protocol Treeish <NSObject>
- (nullable NSArray *) treeishChildren;
@end
NS_ASSUME_NONNULL_END
3 changes: 3 additions & 0 deletions test/SILOptimizer/outliner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,6 @@ extension Operation {
}
}

public func dontCrash(a: Any) {
(a as AnyObject).treeishChildren()
}