Skip to content

Commit ca0d189

Browse files
committed
Add assert and comments to OperandOwnershipClassifier::visitFullApply
I had a difficult time determining to set of possible operand ownership kinds for callee operands.
1 parent dd525d0 commit ca0d189

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

lib/SIL/IR/OperandOwnership.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,24 @@ OperandOwnershipClassifier::visitFullApply(FullApplySite apply) {
443443
? SILArgumentConvention(apply.getSubstCalleeType()->getCalleeConvention())
444444
: apply.getArgumentConvention(op);
445445

446-
return getFunctionArgOwnership(
447-
argConv,
448-
/*hasScopeInCaller*/ apply.beginsCoroutineEvaluation());
446+
auto argOwnership = getFunctionArgOwnership(
447+
argConv, /*hasScopeInCaller*/ apply.beginsCoroutineEvaluation());
448+
449+
// OSSA cleanup needs to handle each of these callee ownership cases.
450+
//
451+
// OperandOwnership::ForwardingConsume is only for thick @callee_owned.
452+
//
453+
// OperandOwnership::Borrow would only happen for a coroutine closure, which
454+
// isn't yet possible.
455+
if (apply.isCalleeOperand(op)) {
456+
assert((argOwnership == OperandOwnership::TrivialUse
457+
|| argOwnership == OperandOwnership::UnownedInstantaneousUse
458+
|| argOwnership == OperandOwnership::InstantaneousUse
459+
|| argOwnership == OperandOwnership::ForwardingConsume
460+
|| argOwnership == OperandOwnership::Borrow) &&
461+
"unsupported callee ownership");
462+
}
463+
return argOwnership;
449464
}
450465

451466
OperandOwnership

0 commit comments

Comments
 (0)