Skip to content

Commit b785a5f

Browse files
authored
Merge pull request #34605 from gottesmm/pr-75f04ac2c27715c84382d9a9e4ca7c0337a3ce30
[ownership] Now that we allow reborrows eliminate isForwardingSubValue it is dead.
2 parents f82e962 + e5c98ad commit b785a5f

File tree

3 files changed

+7
-34
lines changed

3 files changed

+7
-34
lines changed

include/swift/SIL/SILValue.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -692,12 +692,8 @@ class Operand {
692692
/// potentially have to the UseLifetimeConstraint associated with that
693693
/// ownership kind
694694
///
695-
/// NOTE: This is implemented in OperandOwnershipKindMapClassifier.cpp.
696-
///
697-
/// NOTE: The default argument isSubValue is a temporary staging flag that
698-
/// will be removed once borrow scoping is checked by the normal verifier.
699-
OperandOwnershipKindMap
700-
getOwnershipKindMap(bool isForwardingSubValue = false) const;
695+
/// NOTE: This is implemented in OperandOwnership.cpp.
696+
OperandOwnershipKindMap getOwnershipKindMap() const;
701697

702698
/// Returns true if this operand acts as a use that consumes its associated
703699
/// value.

lib/SIL/IR/OperandOwnership.cpp

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class OperandOwnershipKindClassifier
3535
LLVM_ATTRIBUTE_UNUSED SILModule &mod;
3636

3737
const Operand &op;
38-
bool checkingSubObject;
3938

4039
public:
4140
/// Create a new OperandOwnershipKindClassifier.
@@ -45,13 +44,8 @@ class OperandOwnershipKindClassifier
4544
/// should be the subobject and Value should be the parent object. An example
4645
/// of where one would want to do this is in the case of value projections
4746
/// like struct_extract.
48-
OperandOwnershipKindClassifier(
49-
SILModule &mod, const Operand &op,
50-
bool checkingSubObject)
51-
: mod(mod), op(op),
52-
checkingSubObject(checkingSubObject) {}
53-
54-
bool isCheckingSubObject() const { return checkingSubObject; }
47+
OperandOwnershipKindClassifier(SILModule &mod, const Operand &op)
48+
: mod(mod), op(op) {}
5549

5650
SILValue getValue() const { return op.get(); }
5751

@@ -553,15 +547,6 @@ OperandOwnershipKindClassifier::visitReturnInst(ReturnInst *ri) {
553547

554548
OperandOwnershipKindMap
555549
OperandOwnershipKindClassifier::visitEndBorrowInst(EndBorrowInst *i) {
556-
// If we are checking a subobject, make sure that we are from a guaranteed
557-
// basic block argument.
558-
if (isCheckingSubObject()) {
559-
auto *phiArg = cast<SILPhiArgument>(op.get());
560-
(void)phiArg;
561-
return Map::compatibilityMap(ValueOwnershipKind::Guaranteed,
562-
UseLifetimeConstraint::MustBeLive);
563-
}
564-
565550
/// An end_borrow is modeled as invalidating the guaranteed value preventing
566551
/// any further uses of the value.
567552
return Map::compatibilityMap(ValueOwnershipKind::Guaranteed,
@@ -1065,10 +1050,7 @@ OperandOwnershipKindClassifier::visitBuiltinInst(BuiltinInst *bi) {
10651050
// Top Level Entrypoint
10661051
//===----------------------------------------------------------------------===//
10671052

1068-
OperandOwnershipKindMap
1069-
Operand::getOwnershipKindMap(bool isForwardingSubValue) const {
1070-
OperandOwnershipKindClassifier classifier(
1071-
getUser()->getModule(), *this,
1072-
isForwardingSubValue);
1053+
OperandOwnershipKindMap Operand::getOwnershipKindMap() const {
1054+
OperandOwnershipKindClassifier classifier(getUser()->getModule(), *this);
10731055
return classifier.visit(const_cast<SILInstruction *>(getUser()));
10741056
}

lib/SIL/Verifier/SILOwnershipVerifier.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,8 @@ bool SILValueOwnershipChecker::check() {
180180

181181
bool SILValueOwnershipChecker::isCompatibleDefUse(
182182
Operand *op, ValueOwnershipKind ownershipKind) {
183-
bool isGuaranteedSubValue = false;
184-
if (ownershipKind == ValueOwnershipKind::Guaranteed &&
185-
isGuaranteedForwardingInst(op->getUser())) {
186-
isGuaranteedSubValue = true;
187-
}
188183
auto *user = op->getUser();
189-
auto opOwnershipKindMap = op->getOwnershipKindMap(isGuaranteedSubValue);
184+
auto opOwnershipKindMap = op->getOwnershipKindMap();
190185
// If our ownership kind doesn't match, track that we found an error, emit
191186
// an error message optionally and then continue.
192187
if (opOwnershipKindMap.canAcceptKind(ownershipKind)) {

0 commit comments

Comments
 (0)