Skip to content

[region-isolation] Track elements -> regions and regions -> consuming separately. #69787

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
4 changes: 2 additions & 2 deletions include/swift/AST/DiagnosticsSIL.def
Original file line number Diff line number Diff line change
Expand Up @@ -883,8 +883,8 @@ WARNING(transfer_yields_race, none,
"non-sendable value sent across isolation domains that could be concurrently accessed later in this function (%0 access site%select{|s}1 displayed%select{|, %3 more hidden}2)",
(unsigned, bool, bool, unsigned))
WARNING(call_site_transfer_yields_race, none,
"passing argument of non-sendable type %0 from %1 context to %2 context at this call site could yield a race with accesses later in this function (%3 access site%select{|s}4 displayed%select{|, %6 more hidden}5)",
(Type, ActorIsolation, ActorIsolation, unsigned, bool, bool, unsigned))
"passing argument of non-sendable type %0 from %1 context to %2 context at this call site could yield a race with accesses later in this function",
(Type, ActorIsolation, ActorIsolation))
NOTE(possible_racy_access_site, none,
"access here could race", ())

Expand Down
15 changes: 15 additions & 0 deletions include/swift/SIL/ApplySite.h
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,21 @@ class ApplySite {
llvm_unreachable("covered switch");
}

/// Return a list of applied operands of the apply without self.
ArrayRef<Operand> getOperandsWithoutSelf() const {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any other places this can be used?

switch (ApplySiteKind(Inst->getKind())) {
case ApplySiteKind::ApplyInst:
return cast<ApplyInst>(Inst)->getOperandsWithoutSelf();
case ApplySiteKind::BeginApplyInst:
return cast<BeginApplyInst>(Inst)->getOperandsWithoutSelf();
case ApplySiteKind::TryApplyInst:
return cast<TryApplyInst>(Inst)->getOperandsWithoutSelf();
case ApplySiteKind::PartialApplyInst:
llvm_unreachable("Unhandled case");
}
llvm_unreachable("covered switch");
}

/// Returns true if \p op is an operand that passes an indirect
/// result argument to the apply site.
bool isIndirectResultOperand(const Operand &op) const;
Expand Down
20 changes: 15 additions & 5 deletions include/swift/SIL/SILInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -2877,20 +2877,30 @@ class ApplyInstBase<Impl, Base, true>
void setSelfArgument(SILValue V) {
assert(hasSelfArgument() && "Must have a self argument");
assert(getNumArguments() && "Should only be called when Callee has "
"arguments.");
"arguments.");
getArgumentOperands()[getNumArguments() - 1].set(V);
}

OperandValueArrayRef getArgumentsWithoutSelf() const {
assert(hasSelfArgument() && "Must have a self argument");
assert(getNumArguments() && "Should only be called when Callee has "
"at least a self parameter.");
"at least a self parameter.");
ArrayRef<Operand> ops = this->getArgumentOperands();
ArrayRef<Operand> opsWithoutSelf = ArrayRef<Operand>(&ops[0],
ops.size()-1);
if (!hasSelfArgument())
return ops;
auto opsWithoutSelf = ArrayRef<Operand>(&ops[0], ops.size() - 1);
return OperandValueArrayRef(opsWithoutSelf);
}

ArrayRef<Operand> getOperandsWithoutSelf() const {
assert(getNumArguments() && "Should only be called when Callee has "
"at least a self parameter.");
ArrayRef<Operand> ops = this->getArgumentOperands();
if (!hasSelfArgument())
return ops;
auto opsWithoutSelf = ArrayRef<Operand>(&ops[0], ops.size() - 1);
return opsWithoutSelf;
}

llvm::Optional<SILResultInfo> getSingleResult() const {
auto SubstCallee = getSubstCalleeType();
if (SubstCallee->getNumResults() != 1)
Expand Down
Loading