Skip to content

[ownership] Now that we allow reborrows eliminate isForwardingSubValue it is dead. #34605

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
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
8 changes: 2 additions & 6 deletions include/swift/SIL/SILValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -692,12 +692,8 @@ class Operand {
/// potentially have to the UseLifetimeConstraint associated with that
/// ownership kind
///
/// NOTE: This is implemented in OperandOwnershipKindMapClassifier.cpp.
///
/// NOTE: The default argument isSubValue is a temporary staging flag that
/// will be removed once borrow scoping is checked by the normal verifier.
OperandOwnershipKindMap
getOwnershipKindMap(bool isForwardingSubValue = false) const;
/// NOTE: This is implemented in OperandOwnership.cpp.
OperandOwnershipKindMap getOwnershipKindMap() const;

/// Returns true if this operand acts as a use that consumes its associated
/// value.
Expand Down
26 changes: 4 additions & 22 deletions lib/SIL/IR/OperandOwnership.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class OperandOwnershipKindClassifier
LLVM_ATTRIBUTE_UNUSED SILModule &mod;

const Operand &op;
bool checkingSubObject;

public:
/// Create a new OperandOwnershipKindClassifier.
Expand All @@ -45,13 +44,8 @@ class OperandOwnershipKindClassifier
/// should be the subobject and Value should be the parent object. An example
/// of where one would want to do this is in the case of value projections
/// like struct_extract.
OperandOwnershipKindClassifier(
SILModule &mod, const Operand &op,
bool checkingSubObject)
: mod(mod), op(op),
checkingSubObject(checkingSubObject) {}

bool isCheckingSubObject() const { return checkingSubObject; }
OperandOwnershipKindClassifier(SILModule &mod, const Operand &op)
: mod(mod), op(op) {}

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

Expand Down Expand Up @@ -552,15 +546,6 @@ OperandOwnershipKindClassifier::visitReturnInst(ReturnInst *ri) {

OperandOwnershipKindMap
OperandOwnershipKindClassifier::visitEndBorrowInst(EndBorrowInst *i) {
// If we are checking a subobject, make sure that we are from a guaranteed
// basic block argument.
if (isCheckingSubObject()) {
auto *phiArg = cast<SILPhiArgument>(op.get());
(void)phiArg;
return Map::compatibilityMap(ValueOwnershipKind::Guaranteed,
UseLifetimeConstraint::MustBeLive);
}

/// An end_borrow is modeled as invalidating the guaranteed value preventing
/// any further uses of the value.
return Map::compatibilityMap(ValueOwnershipKind::Guaranteed,
Expand Down Expand Up @@ -1054,10 +1039,7 @@ OperandOwnershipKindClassifier::visitBuiltinInst(BuiltinInst *bi) {
// Top Level Entrypoint
//===----------------------------------------------------------------------===//

OperandOwnershipKindMap
Operand::getOwnershipKindMap(bool isForwardingSubValue) const {
OperandOwnershipKindClassifier classifier(
getUser()->getModule(), *this,
isForwardingSubValue);
OperandOwnershipKindMap Operand::getOwnershipKindMap() const {
OperandOwnershipKindClassifier classifier(getUser()->getModule(), *this);
return classifier.visit(const_cast<SILInstruction *>(getUser()));
}
7 changes: 1 addition & 6 deletions lib/SIL/Verifier/SILOwnershipVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,8 @@ bool SILValueOwnershipChecker::check() {

bool SILValueOwnershipChecker::isCompatibleDefUse(
Operand *op, ValueOwnershipKind ownershipKind) {
bool isGuaranteedSubValue = false;
if (ownershipKind == ValueOwnershipKind::Guaranteed &&
isGuaranteedForwardingInst(op->getUser())) {
isGuaranteedSubValue = true;
}
auto *user = op->getUser();
auto opOwnershipKindMap = op->getOwnershipKindMap(isGuaranteedSubValue);
auto opOwnershipKindMap = op->getOwnershipKindMap();
// If our ownership kind doesn't match, track that we found an error, emit
// an error message optionally and then continue.
if (opOwnershipKindMap.canAcceptKind(ownershipKind)) {
Expand Down