Skip to content

Update operand ownership of some concurrency instructions #66685

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 1 commit into from
Jun 20, 2023
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
32 changes: 12 additions & 20 deletions lib/SIL/IR/OperandOwnership.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,8 @@ OPERAND_OWNERSHIP(ForwardingConsume, Throw)
OPERAND_OWNERSHIP(InteriorPointer, RefElementAddr)
OPERAND_OWNERSHIP(InteriorPointer, RefTailAddr)
OPERAND_OWNERSHIP(InteriorPointer, OpenExistentialBox)
// FIXME: HopToExecutorInst should be an instantaneous use.
OPERAND_OWNERSHIP(InteriorPointer, HopToExecutor)
OPERAND_OWNERSHIP(InteriorPointer, ExtractExecutor)
OPERAND_OWNERSHIP(InstantaneousUse, HopToExecutor)
OPERAND_OWNERSHIP(PointerEscape, ExtractExecutor)

// Instructions that propagate a value within a borrow scope.
OPERAND_OWNERSHIP(GuaranteedForwarding, TupleExtract)
Expand Down Expand Up @@ -894,12 +893,8 @@ OperandOwnershipBuiltinClassifier::visitCreateAsyncTask(BuiltinInst *bi,
// The function operand is consumed by the new task.
if (&op == &bi->getOperandRef(PARAMETER_INDEX_CREATE_ASYNC_TASK_FUTURE_FUNCTION))
return OperandOwnership::DestroyingConsume;

// FIXME: These are considered InteriorPointer because they may propagate a
// pointer into a borrowed values. If they do not propagate an interior pointer,
// then they should be InstantaneousUse instead and should not require a
// guaranteed value.
return OperandOwnership::InteriorPointer;

return OperandOwnership::InstantaneousUse;
}

OperandOwnership
Expand All @@ -908,12 +903,8 @@ OperandOwnershipBuiltinClassifier::visitCreateAsyncTaskInGroup(BuiltinInst *bi,
// The function operand is consumed by the new task.
if (&op == &bi->getOperandRef(PARAMETER_INDEX_CREATE_ASYNC_TASK_GROUP_FUTURE_FUNCTION))
return OperandOwnership::DestroyingConsume;

// FIXME: These are considered InteriorPointer because they may propagate a
// pointer into a borrowed values. If they do not propagate an interior pointer,
// then they should be InstantaneousUse instead and should not require a
// guaranteed value.
return OperandOwnership::InteriorPointer;

return OperandOwnership::InstantaneousUse;
}

OperandOwnership OperandOwnershipBuiltinClassifier::
Expand Down Expand Up @@ -945,12 +936,13 @@ visitResumeThrowingContinuationThrowing(BuiltinInst *bi, StringRef attr) {

BUILTIN_OPERAND_OWNERSHIP(InstantaneousUse, TaskRunInline)

BUILTIN_OPERAND_OWNERSHIP(InteriorPointer, CancelAsyncTask)
BUILTIN_OPERAND_OWNERSHIP(InteriorPointer, InitializeDefaultActor)
BUILTIN_OPERAND_OWNERSHIP(InteriorPointer, DestroyDefaultActor)
BUILTIN_OPERAND_OWNERSHIP(InstantaneousUse, CancelAsyncTask)
BUILTIN_OPERAND_OWNERSHIP(InstantaneousUse, InitializeDefaultActor)
BUILTIN_OPERAND_OWNERSHIP(InstantaneousUse, DestroyDefaultActor)

BUILTIN_OPERAND_OWNERSHIP(InteriorPointer, InitializeDistributedRemoteActor)
BUILTIN_OPERAND_OWNERSHIP(InteriorPointer, InitializeNonDefaultDistributedActor)
BUILTIN_OPERAND_OWNERSHIP(InstantaneousUse, InitializeDistributedRemoteActor)
BUILTIN_OPERAND_OWNERSHIP(InstantaneousUse,
InitializeNonDefaultDistributedActor)

BUILTIN_OPERAND_OWNERSHIP(PointerEscape, AutoDiffAllocateSubcontext)
BUILTIN_OPERAND_OWNERSHIP(PointerEscape, AutoDiffProjectTopLevelSubcontext)
Expand Down
7 changes: 7 additions & 0 deletions lib/SIL/Verifier/SILVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,13 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
"Operand constraint should never have an unowned preferred "
"kind since guaranteed and owned values can always be passed "
"in unowned positions");

require(operand.getOperandOwnership() !=
OperandOwnership::InteriorPointer ||
InteriorPointerOperandKind::get(&operand) !=
InteriorPointerOperandKind::Invalid,
"All operands with InteriorPointer operand ownership should be "
"added to the InteriorPointerOperand utility");
}
}

Expand Down