Skip to content

Commit 7680332

Browse files
authored
Merge pull request #69906 from gottesmm/use-tracked-transfer-inst
[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
2 parents 975519b + 46c4da3 commit 7680332

File tree

9 files changed

+700
-762
lines changed

9 files changed

+700
-762
lines changed

include/swift/SIL/ApplySite.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,20 @@ class ApplySite {
500500
llvm_unreachable("covered switch");
501501
}
502502

503+
MutableArrayRef<Operand> getOperandsWithoutSelf() {
504+
switch (ApplySiteKind(Inst->getKind())) {
505+
case ApplySiteKind::ApplyInst:
506+
return cast<ApplyInst>(Inst)->getOperandsWithoutSelf();
507+
case ApplySiteKind::BeginApplyInst:
508+
return cast<BeginApplyInst>(Inst)->getOperandsWithoutSelf();
509+
case ApplySiteKind::TryApplyInst:
510+
return cast<TryApplyInst>(Inst)->getOperandsWithoutSelf();
511+
case ApplySiteKind::PartialApplyInst:
512+
llvm_unreachable("Unhandled case");
513+
}
514+
llvm_unreachable("covered switch");
515+
}
516+
503517
/// Returns true if \p op is an operand that passes an indirect
504518
/// result argument to the apply site.
505519
bool isIndirectResultOperand(const Operand &op) const;

include/swift/SIL/SILInstruction.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2901,6 +2901,16 @@ class ApplyInstBase<Impl, Base, true>
29012901
return opsWithoutSelf;
29022902
}
29032903

2904+
MutableArrayRef<Operand> getOperandsWithoutSelf() {
2905+
assert(getNumArguments() && "Should only be called when Callee has "
2906+
"at least a self parameter.");
2907+
MutableArrayRef<Operand> ops = this->getArgumentOperands();
2908+
if (!hasSelfArgument())
2909+
return ops;
2910+
auto opsWithoutSelf = ops.drop_back();
2911+
return opsWithoutSelf;
2912+
}
2913+
29042914
llvm::Optional<SILResultInfo> getSingleResult() const {
29052915
auto SubstCallee = getSubstCalleeType();
29062916
if (SubstCallee->getNumResults() != 1)

include/swift/SIL/SILLocation.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define SWIFT_SIL_LOCATION_H
1515

1616
#include "llvm/ADT/PointerUnion.h"
17+
#include "swift/AST/ASTNode.h"
1718
#include "swift/Basic/SourceLoc.h"
1819
#include "swift/SIL/SILAllocated.h"
1920
#include "swift/AST/TypeAlignments.h"
@@ -414,6 +415,26 @@ class SILLocation {
414415
return castNodeTo<T>(getPrimaryASTNode());
415416
}
416417

418+
/// If this SILLocation contains an ASTNode, return that node.
419+
ASTNode getASTNode() const {
420+
if (!isASTNode())
421+
return ASTNode();
422+
// ASTNode is a superset of PrimaryASTNode so we can just cast it, once we
423+
// remove the bit stolen by ASTNodeTy from the underlying ASTNode pointer.
424+
auto primaryNode = getPrimaryASTNode().getPointer();
425+
426+
if (auto *stmt = primaryNode.dyn_cast<Stmt *>())
427+
return {stmt};
428+
if (auto *expr = primaryNode.dyn_cast<Expr *>())
429+
return {expr};
430+
if (auto *decl = primaryNode.dyn_cast<Decl *>())
431+
return {decl};
432+
if (auto *pattern = primaryNode.dyn_cast<Pattern *>())
433+
return {pattern};
434+
435+
return ASTNode();
436+
}
437+
417438
/// Return the location as a DeclContext or null.
418439
DeclContext *getAsDeclContext() const;
419440

0 commit comments

Comments
 (0)