Skip to content

Commit 14e9a01

Browse files
committed
BorrowedLifetimeExtender minor cleanup
1 parent d71e450 commit 14e9a01

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

lib/SILOptimizer/Utils/OwnershipOptUtils.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ static bool canFixUpOwnershipForRAUW(SILValue oldValue, SILValue newValue,
230230
/// extending %ownedValue's liveness to new paths and hopefully simplifies
231231
/// downstream optimization and debugging. Unnecessary copies could be
232232
/// avoided with simple dominance check if it becomes desirable to do so.
233-
struct BorrowedLifetimeExtender {
233+
class BorrowedLifetimeExtender {
234234
BorrowedValue borrowedValue;
235235

236236
// Owned value currently being extended over borrowedValue.
@@ -245,6 +245,21 @@ struct BorrowedLifetimeExtender {
245245
/// utility and OSSA representation are stable.
246246
SWIFT_ASSERT_ONLY_DECL(llvm::SmallDenseSet<PhiOperand, 4> reborrowedOperands);
247247

248+
public:
249+
/// Precondition: \p borrowedValue must introduce a local borrow scope
250+
/// (begin_borrow, load_borrow, & phi).
251+
BorrowedLifetimeExtender(BorrowedValue borrowedValue,
252+
InstModCallbacks &callbacks)
253+
: borrowedValue(borrowedValue), callbacks(callbacks) {
254+
assert(borrowedValue.isLocalScope() && "expect a valid borrowed value");
255+
}
256+
257+
/// Extend \p ownedValue over this extended borrow scope.
258+
///
259+
/// Precondition: \p ownedValue dominates this borrowed value.
260+
void extendOverBorrowScopeAndConsume(SILValue ownedValue);
261+
262+
protected:
248263
/// Initially map the reborrowed phi to an invalid value prior to creating the
249264
/// owned phi.
250265
void discoverReborrow(PhiValue reborrowedPhi) {
@@ -282,21 +297,6 @@ struct BorrowedLifetimeExtender {
282297
return SILValue();
283298
}
284299

285-
public:
286-
/// Precondition: \p borrowedValue must introduce a local borrow scope
287-
/// (begin_borrow, load_borrow, & phi).
288-
BorrowedLifetimeExtender(BorrowedValue borrowedValue,
289-
InstModCallbacks &callbacks)
290-
: borrowedValue(borrowedValue), callbacks(callbacks) {
291-
assert(borrowedValue.isLocalScope() && "expect a valid borrowed value");
292-
}
293-
294-
/// Extend \p ownedValue over this extended borrow scope.
295-
///
296-
/// Precondition: \p ownedValue dominates this borrowed value.
297-
void extendOverBorrowScopeAndConsume(SILValue ownedValue);
298-
299-
protected:
300300
void analyzeExtendedScope();
301301

302302
SILValue createCopyAtEdge(PhiOperand reborrowOper);

0 commit comments

Comments
 (0)