Skip to content

Commit 97d69ab

Browse files
committed
Outliner: Make sure that the argument convention is guaranteed or owned
rdar://57759220
1 parent 01f46b3 commit 97d69ab

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/SILOptimizer/Transforms/Outliner.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,13 @@ BridgedArgument BridgedArgument::match(unsigned ArgIdx, SILValue Arg,
764764
Enum->getOperand() != BridgeCall || !BridgeCall->hasOneUse())
765765
return BridgedArgument();
766766

767+
auto &selfArg = FullApplySite(BridgeCall).getSelfArgumentOperand();
768+
auto selfConvention =
769+
FullApplySite(BridgeCall).getArgumentConvention(selfArg);
770+
if (selfConvention != SILArgumentConvention::Direct_Guaranteed &&
771+
selfConvention != SILArgumentConvention::Direct_Owned)
772+
return BridgedArgument();
773+
767774
auto BridgedValue = BridgeCall->getArgument(0);
768775
auto Next = std::next(SILBasicBlock::iterator(Enum));
769776
if (Next == Enum->getParent()->end())

test/SILOptimizer/outliner.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,8 @@ public class Foo : NSObject {
217217
return true
218218
}
219219
}
220+
221+
public func testCalendar() {
222+
let formatter = DateFormatter()
223+
formatter.calendar = Calendar(identifier: .gregorian)
224+
}

0 commit comments

Comments
 (0)