Skip to content

Commit

Permalink
Merge pull request #69906 from gottesmm/use-tracked-transfer-inst
Browse files Browse the repository at this point in the history
[region-isolation] Since we now propagate the transferred instruction, use that to emit the error instead of attempting to infer the transfer instruction for a requires
  • Loading branch information
gottesmm committed Nov 16, 2023
2 parents 975519b + 46c4da3 commit 7680332
Show file tree
Hide file tree
Showing 9 changed files with 700 additions and 762 deletions.
14 changes: 14 additions & 0 deletions include/swift/SIL/ApplySite.h
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,20 @@ class ApplySite {
llvm_unreachable("covered switch");
}

MutableArrayRef<Operand> getOperandsWithoutSelf() {
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
10 changes: 10 additions & 0 deletions include/swift/SIL/SILInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -2901,6 +2901,16 @@ class ApplyInstBase<Impl, Base, true>
return opsWithoutSelf;
}

MutableArrayRef<Operand> getOperandsWithoutSelf() {
assert(getNumArguments() && "Should only be called when Callee has "
"at least a self parameter.");
MutableArrayRef<Operand> ops = this->getArgumentOperands();
if (!hasSelfArgument())
return ops;
auto opsWithoutSelf = ops.drop_back();
return opsWithoutSelf;
}

llvm::Optional<SILResultInfo> getSingleResult() const {
auto SubstCallee = getSubstCalleeType();
if (SubstCallee->getNumResults() != 1)
Expand Down
21 changes: 21 additions & 0 deletions include/swift/SIL/SILLocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define SWIFT_SIL_LOCATION_H

#include "llvm/ADT/PointerUnion.h"
#include "swift/AST/ASTNode.h"
#include "swift/Basic/SourceLoc.h"
#include "swift/SIL/SILAllocated.h"
#include "swift/AST/TypeAlignments.h"
Expand Down Expand Up @@ -414,6 +415,26 @@ class SILLocation {
return castNodeTo<T>(getPrimaryASTNode());
}

/// If this SILLocation contains an ASTNode, return that node.
ASTNode getASTNode() const {
if (!isASTNode())
return ASTNode();
// ASTNode is a superset of PrimaryASTNode so we can just cast it, once we
// remove the bit stolen by ASTNodeTy from the underlying ASTNode pointer.
auto primaryNode = getPrimaryASTNode().getPointer();

if (auto *stmt = primaryNode.dyn_cast<Stmt *>())
return {stmt};
if (auto *expr = primaryNode.dyn_cast<Expr *>())
return {expr};
if (auto *decl = primaryNode.dyn_cast<Decl *>())
return {decl};
if (auto *pattern = primaryNode.dyn_cast<Pattern *>())
return {pattern};

return ASTNode();
}

/// Return the location as a DeclContext or null.
DeclContext *getAsDeclContext() const;

Expand Down
Loading

0 comments on commit 7680332

Please sign in to comment.