Skip to content

Commit 5e2b705

Browse files
authored
Merge pull request #19131 from gottesmm/pr-67d16ab8862dce3cff561b2a4dbee16514133383
2 parents 0c2d874 + 0290cd4 commit 5e2b705

File tree

20 files changed

+40
-242
lines changed

20 files changed

+40
-242
lines changed

include/swift/SIL/SILBuilder.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -727,12 +727,6 @@ class SILBuilder {
727727
EndBorrowInst(getSILDebugLocation(Loc), BorrowedValue));
728728
}
729729

730-
EndBorrowArgumentInst *createEndBorrowArgument(SILLocation Loc,
731-
SILValue Arg) {
732-
return insert(new (getModule()) EndBorrowArgumentInst(
733-
getSILDebugLocation(Loc), cast<SILArgument>(Arg)));
734-
}
735-
736730
BeginAccessInst *createBeginAccess(SILLocation loc, SILValue address,
737731
SILAccessKind accessKind,
738732
SILAccessEnforcement enforcement,

include/swift/SIL/SILCloner.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -778,15 +778,6 @@ void SILCloner<ImplClass>::visitEndBorrowInst(EndBorrowInst *Inst) {
778778
getOpValue(Inst->getOperand()), SILValue()));
779779
}
780780

781-
template <typename ImplClass>
782-
void SILCloner<ImplClass>::visitEndBorrowArgumentInst(
783-
EndBorrowArgumentInst *Inst) {
784-
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
785-
doPostProcess(
786-
Inst, getBuilder().createEndBorrowArgument(
787-
getOpLocation(Inst->getLoc()), getOpValue(Inst->getOperand())));
788-
}
789-
790781
template <typename ImplClass>
791782
void SILCloner<ImplClass>::visitBeginAccessInst(BeginAccessInst *Inst) {
792783
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));

include/swift/SIL/SILInstruction.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3221,18 +3221,6 @@ class EndBorrowInst
32213221
}
32223222
};
32233223

3224-
/// Represents the end of a borrow scope for an argument. The reason why this is
3225-
/// separate from end_borrow is that an argument is not borrowed from a
3226-
/// specific SSA value. Instead it is borrowed from potentially many different
3227-
/// incoming values.
3228-
class EndBorrowArgumentInst
3229-
: public UnaryInstructionBase<SILInstructionKind::EndBorrowArgumentInst,
3230-
NonValueInstruction> {
3231-
friend class SILBuilder;
3232-
3233-
EndBorrowArgumentInst(SILDebugLocation DebugLoc, SILArgument *Arg);
3234-
};
3235-
32363224
/// Different kinds of access.
32373225
enum class SILAccessKind : uint8_t {
32383226
/// An access which takes uninitialized memory and initializes it.

include/swift/SIL/SILNodes.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,6 @@ NON_VALUE_INST(DestroyValueInst, destroy_value,
598598
SILInstruction, MayHaveSideEffects, MayRelease)
599599
NON_VALUE_INST(EndBorrowInst, end_borrow,
600600
SILInstruction, MayHaveSideEffects, DoesNotRelease)
601-
NON_VALUE_INST(EndBorrowArgumentInst, end_borrow_argument,
602-
SILInstruction, MayHaveSideEffects, DoesNotRelease)
603601
NON_VALUE_INST(EndAccessInst, end_access,
604602
SILInstruction, MayHaveSideEffects, DoesNotRelease)
605603
NON_VALUE_INST(BeginUnpairedAccessInst, begin_unpaired_access,

lib/IRGen/IRGenSIL.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,9 +1049,6 @@ class IRGenSILFunction :
10491049
void visitEndBorrowInst(EndBorrowInst *i) {
10501050
llvm_unreachable("unimplemented");
10511051
}
1052-
void visitEndBorrowArgumentInst(EndBorrowArgumentInst *i) {
1053-
llvm_unreachable("unimplemented");
1054-
}
10551052
void visitStoreBorrowInst(StoreBorrowInst *i) {
10561053
llvm_unreachable("unimplemented");
10571054
}

lib/ParseSIL/ParseSIL.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2680,7 +2680,6 @@ bool SILParser::parseSILInstruction(SILBuilder &B) {
26802680
UNARY_INSTRUCTION(CopyValue)
26812681
UNARY_INSTRUCTION(DestroyValue)
26822682
UNARY_INSTRUCTION(CondFail)
2683-
UNARY_INSTRUCTION(EndBorrowArgument)
26842683
UNARY_INSTRUCTION(EndBorrow)
26852684
UNARY_INSTRUCTION(DestructureStruct)
26862685
UNARY_INSTRUCTION(DestructureTuple)

lib/SIL/MemAccessUtils.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,6 @@ void swift::visitAccessedAddress(SILInstruction *I,
699699
case SILInstructionKind::DestroyValueInst:
700700
case SILInstructionKind::EndAccessInst:
701701
case SILInstructionKind::EndApplyInst:
702-
case SILInstructionKind::EndBorrowArgumentInst:
703702
case SILInstructionKind::EndBorrowInst:
704703
case SILInstructionKind::EndUnpairedAccessInst:
705704
case SILInstructionKind::EndLifetimeInst:

lib/SIL/SILInstructions.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -790,10 +790,6 @@ StoreBorrowInst::StoreBorrowInst(SILDebugLocation DebugLoc, SILValue Src,
790790
: InstructionBase(DebugLoc, Dest->getType()),
791791
Operands(this, Src, Dest) {}
792792

793-
EndBorrowArgumentInst::EndBorrowArgumentInst(SILDebugLocation DebugLoc,
794-
SILArgument *Arg)
795-
: UnaryInstructionBase(DebugLoc, SILValue(Arg)) {}
796-
797793
StringRef swift::getSILAccessKindName(SILAccessKind kind) {
798794
switch (kind) {
799795
case SILAccessKind::Init: return "init";

lib/SIL/SILOwnershipVerifier.cpp

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -610,21 +610,6 @@ OwnershipCompatibilityUseChecker::visitDeallocPartialRefInst(
610610
UseLifetimeConstraint::MustBeLive};
611611
}
612612

613-
OwnershipUseCheckerResult
614-
OwnershipCompatibilityUseChecker::visitEndBorrowArgumentInst(
615-
EndBorrowArgumentInst *I) {
616-
// If we are currently checking an end_borrow_argument as a subobject, then we
617-
// treat this as just a use.
618-
if (isCheckingSubObject())
619-
return {true, UseLifetimeConstraint::MustBeLive};
620-
621-
// Otherwise, we must be checking an actual argument. Make sure it is guaranteed!
622-
auto lifetimeConstraint = hasExactOwnership(ValueOwnershipKind::Guaranteed)
623-
? UseLifetimeConstraint::MustBeInvalidated
624-
: UseLifetimeConstraint::MustBeLive;
625-
return {true, lifetimeConstraint};
626-
}
627-
628613
OwnershipUseCheckerResult
629614
OwnershipCompatibilityUseChecker::visitSelectEnumInst(SelectEnumInst *I) {
630615
if (getValue() == I->getEnumOperand()) {
@@ -1551,10 +1536,10 @@ void SILValueOwnershipChecker::gatherUsers(
15511536
continue;
15521537
}
15531538

1554-
// Otherwise if we have a terminator, add any as uses any
1555-
// end_borrow_argument to ensure that the subscope is completely enclsed
1556-
// within the super scope. all of the arguments to the work list. We require
1557-
// all of our arguments to be either trivial or guaranteed.
1539+
// Otherwise if we have a terminator, add any as uses any end_borrow to
1540+
// ensure that the subscope is completely enclsed within the super
1541+
// scope. all of the arguments to the work list. We require all of our
1542+
// arguments to be either trivial or guaranteed.
15581543
for (auto &Succ : TI->getSuccessors()) {
15591544
auto *BB = Succ.getBB();
15601545

lib/SIL/SILPrinter.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,10 +1278,6 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
12781278
*this << getIDAndType(EBI->getOperand());
12791279
}
12801280

1281-
void visitEndBorrowArgumentInst(EndBorrowArgumentInst *EBAI) {
1282-
*this << getIDAndType(EBAI->getOperand());
1283-
}
1284-
12851281
void visitAssignInst(AssignInst *AI) {
12861282
*this << Ctx.getID(AI->getSrc()) << " to " << getIDAndType(AI->getDest());
12871283
}

lib/SILGen/SILGenExpr.cpp

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -163,22 +163,21 @@ SILGenFunction::emitManagedBeginBorrow(SILLocation loc, SILValue v,
163163
namespace {
164164

165165
struct EndBorrowCleanup : Cleanup {
166-
SILValue originalValue;
167166
SILValue borrowedValue;
168167

169-
EndBorrowCleanup(SILValue originalValue, SILValue borrowedValue)
170-
: originalValue(originalValue), borrowedValue(borrowedValue) {}
168+
EndBorrowCleanup(SILValue borrowedValue)
169+
: borrowedValue(borrowedValue) {}
171170

172171
void emit(SILGenFunction &SGF, CleanupLocation l,
173172
ForUnwind_t forUnwind) override {
174-
SGF.B.createEndBorrow(l, borrowedValue, originalValue);
173+
SGF.B.createEndBorrow(l, borrowedValue);
175174
}
176175

177176
void dump(SILGenFunction &) const override {
178177
#ifndef NDEBUG
179178
llvm::errs() << "EndBorrowCleanup "
180179
<< "State:" << getState() << "\n"
181-
<< "original:" << originalValue << "borrowed:" << borrowedValue
180+
<< "borrowed:" << borrowedValue
182181
<< "\n";
183182
#endif
184183
}
@@ -271,29 +270,6 @@ SILGenFunction::emitFormalEvaluationManagedBorrowedRValueWithCleanup(
271270
return ManagedValue(borrowed, CleanupHandle::invalid());
272271
}
273272

274-
namespace {
275-
276-
struct EndBorrowArgumentCleanup : Cleanup {
277-
SILPHIArgument *arg;
278-
279-
EndBorrowArgumentCleanup(SILPHIArgument *arg) : arg(arg) {}
280-
281-
void emit(SILGenFunction &SGF, CleanupLocation l,
282-
ForUnwind_t forUnwind) override {
283-
SGF.B.createEndBorrowArgument(l, arg);
284-
}
285-
286-
void dump(SILGenFunction &) const override {
287-
#ifndef NDEBUG
288-
llvm::errs() << "EndBorrowArgumentCleanup "
289-
<< "State:" << getState() << "\n"
290-
<< "argument: " << *arg << "\n";
291-
#endif
292-
}
293-
};
294-
295-
} // end anonymous namespace
296-
297273
ManagedValue
298274
SILGenFunction::emitManagedBorrowedArgumentWithCleanup(SILPHIArgument *arg) {
299275
if (arg->getOwnershipKind() == ValueOwnershipKind::Trivial ||
@@ -302,7 +278,7 @@ SILGenFunction::emitManagedBorrowedArgumentWithCleanup(SILPHIArgument *arg) {
302278
}
303279

304280
assert(arg->getOwnershipKind() == ValueOwnershipKind::Guaranteed);
305-
Cleanups.pushCleanup<EndBorrowArgumentCleanup>(arg);
281+
Cleanups.pushCleanup<EndBorrowCleanup>(arg);
306282
return ManagedValue(arg, CleanupHandle::invalid());
307283
}
308284

@@ -327,7 +303,7 @@ ManagedValue SILGenFunction::emitManagedBorrowedRValueWithCleanup(
327303
return ManagedValue::forUnmanaged(borrowed);
328304

329305
if (borrowed->getType().isObject()) {
330-
Cleanups.pushCleanup<EndBorrowCleanup>(original, borrowed);
306+
Cleanups.pushCleanup<EndBorrowCleanup>(borrowed);
331307
}
332308

333309
return ManagedValue(borrowed, CleanupHandle::invalid());

lib/SILOptimizer/Utils/SILInliner.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,6 @@ InlineCost swift::instructionInlineCost(SILInstruction &I) {
507507
case SILInstructionKind::ConstStringLiteralInst:
508508
case SILInstructionKind::FixLifetimeInst:
509509
case SILInstructionKind::EndBorrowInst:
510-
case SILInstructionKind::EndBorrowArgumentInst:
511510
case SILInstructionKind::BeginBorrowInst:
512511
case SILInstructionKind::MarkDependenceInst:
513512
case SILInstructionKind::FunctionRefInst:

lib/Serialization/DeserializeSIL.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,6 @@ bool SILDeserializer::readSILInstruction(SILFunction *Fn, SILBasicBlock *BB,
16411641
REFCOUNTING_INSTRUCTION(SetDeallocating)
16421642
UNARY_INSTRUCTION(DeinitExistentialAddr)
16431643
UNARY_INSTRUCTION(DeinitExistentialValue)
1644-
UNARY_INSTRUCTION(EndBorrowArgument)
16451644
UNARY_INSTRUCTION(EndBorrow)
16461645
UNARY_INSTRUCTION(DestroyAddr)
16471646
UNARY_INSTRUCTION(Return)

lib/Serialization/SerializeSIL.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,6 @@ void SILSerializer::writeSILInstruction(const SILInstruction &SI) {
12151215
case SILInstructionKind::DestructureTupleInst:
12161216
case SILInstructionKind::RetainValueAddrInst:
12171217
case SILInstructionKind::UnmanagedRetainValueInst:
1218-
case SILInstructionKind::EndBorrowArgumentInst:
12191218
case SILInstructionKind::EndBorrowInst:
12201219
case SILInstructionKind::CopyValueInst:
12211220
case SILInstructionKind::DestroyValueInst:

test/SIL/Parser/borrow_argument.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import Builtin
66

77
// CHECK-LABEL: sil @borrow_argument_test : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () {
88
// CHECK: bb1([[PHIBBARG:%.*]] : @guaranteed $Builtin.NativeObject):
9-
// CHECK: end_borrow_argument [[PHIBBARG]] : $Builtin.NativeObject
9+
// CHECK: end_borrow [[PHIBBARG]] : $Builtin.NativeObject
1010
sil @borrow_argument_test : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () {
1111
bb0(%0 : @guaranteed $Builtin.NativeObject):
1212
br bb1(%0 : $Builtin.NativeObject)
1313

1414
bb1(%1 : @guaranteed $Builtin.NativeObject):
15-
end_borrow_argument %1 : $Builtin.NativeObject
15+
end_borrow %1 : $Builtin.NativeObject
1616
%4 = tuple()
1717
return %4 : $()
1818
}

test/SIL/Parser/ownership_arguments.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ bb0(%0 : @owned $Builtin.NativeObject, %1 : @unowned $Builtin.NativeObject, %2 :
1414

1515
bb1(%4 : @owned $Builtin.NativeObject, %5 : @unowned $Builtin.NativeObject, %6 : @guaranteed $Builtin.NativeObject, %7 : @trivial $Builtin.Int32):
1616
destroy_value %4 : $Builtin.NativeObject
17-
end_borrow_argument %6 : $Builtin.NativeObject
17+
end_borrow %6 : $Builtin.NativeObject
1818
%9999 = tuple()
1919
return %9999 : $()
2020
}

test/SIL/Serialization/borrow_argument.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import Builtin
1010

1111
// CHECK-LABEL: sil [serialized] @borrow_argument_test : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () {
1212
// CHECK: bb1([[PHIBBARG:%.*]] : @guaranteed $Builtin.NativeObject):
13-
// CHECK: end_borrow_argument [[PHIBBARG]] : $Builtin.NativeObject
13+
// CHECK: end_borrow [[PHIBBARG]] : $Builtin.NativeObject
1414
sil [serialized] @borrow_argument_test : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () {
1515
bb0(%0 : @guaranteed $Builtin.NativeObject):
1616
br bb1(%0 : $Builtin.NativeObject)
1717

1818
bb1(%1 : @guaranteed $Builtin.NativeObject):
19-
end_borrow_argument %1 : $Builtin.NativeObject
19+
end_borrow %1 : $Builtin.NativeObject
2020
%4 = tuple()
2121
return %4 : $()
2222
}

0 commit comments

Comments
 (0)