@@ -943,23 +943,9 @@ BeginBorrowInst *OwnershipLifetimeExtender::borrowCopyOverGuaranteedUses(
943
943
makeUserRange (guaranteedUsePoints));
944
944
}
945
945
946
- // Return the borrow position when replacing guaranteedValue with newValue.
947
- //
948
- // Precondition: newValue's block dominates and reaches guaranteedValue's block.
949
- //
950
- // Postcondition: The returned instruction's block is guaranteedValue's block.
951
- //
952
- // If \p newValue and \p guaranteedValue are in the same block, borrow at the
953
- // newValue just in case it is defined later in the block (to avoid scanning
954
- // instructions). Otherwise, borrow in the guaranteedValue's block to avoid
955
- // introducing the borrow scope too early--not only would this require extra
956
- // cleanup, but it would hinder optimization.
957
- static SILBasicBlock::iterator getBorrowPoint (SILValue newValue,
958
- SILValue guaranteedValue) {
959
- if (newValue->getParentBlock () == guaranteedValue->getParentBlock ())
960
- return newValue->getNextInstruction ()->getIterator ();
961
-
962
- return guaranteedValue->getNextInstruction ()->getIterator ();
946
+ // Return the borrow position when replacing oldValue.
947
+ static SILBasicBlock::iterator getBorrowPoint (SILValue oldValue) {
948
+ return oldValue->getDefiningInsertionPoint ()->getIterator ();
963
949
}
964
950
965
951
// / Borrow \p newValue over the lifetime of \p guaranteedValue. Return the
@@ -991,7 +977,7 @@ OwnershipLifetimeExtender::borrowOverValue(SILValue newValue,
991
977
return newValue;
992
978
993
979
// FIXME: use GuaranteedOwnershipExtension
994
- auto borrowPt = getBorrowPoint (newValue, guaranteedValue);
980
+ auto borrowPt = getBorrowPoint (guaranteedValue);
995
981
return borrowCopyOverGuaranteedUses (
996
982
newValue, borrowPt, ArrayRef<Operand *>(ctx.guaranteedUsePoints ));
997
983
}
@@ -1151,7 +1137,7 @@ SILValue OwnershipRAUWPrepare::prepareUnowned(SILValue newValue) {
1151
1137
}
1152
1138
1153
1139
auto extender = getLifetimeExtender ();
1154
- auto borrowPt = getBorrowPoint (newValue, oldValue);
1140
+ auto borrowPt = getBorrowPoint (oldValue);
1155
1141
SILValue borrow = extender.borrowCopyOverGuaranteedUses (
1156
1142
newValue, borrowPt, oldValue->getUses ());
1157
1143
return borrow;
@@ -1267,7 +1253,7 @@ OwnershipRAUWHelper::getReplacementAddress() {
1267
1253
// value. Then we RAUW as appropriate.
1268
1254
OwnershipLifetimeExtender extender{*ctx};
1269
1255
auto base = ctx->extraAddressFixupInfo .base ;
1270
- auto borrowPt = getBorrowPoint (newValue, oldValue);
1256
+ auto borrowPt = getBorrowPoint (oldValue);
1271
1257
// FIXME: why does this use allAddressUsesFromOldValue instead of
1272
1258
// guaranteedUsePoints?
1273
1259
BeginBorrowInst *bbi = extender.borrowCopyOverGuaranteedUses (
0 commit comments