Skip to content

Commit 0c09d42

Browse files
committed
Comment OSSA APIs makeNewValueAvailable & endLifetimeAtLeakingBlocks
1 parent d50f220 commit 0c09d42

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

include/swift/SILOptimizer/Utils/InstOptUtils.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,10 +708,18 @@ makeCopiedValueAvailable(SILValue value, SILBasicBlock *inBlock);
708708
/// Given a newly created @owned value \p value without any uses, this utility
709709
/// inserts control equivalent copy and destroy at leaking blocks to adjust
710710
/// ownership and make \p value available for use at \p inBlock.
711+
///
712+
/// inBlock must be the only point at which \p value will be consumed. If this
713+
/// consuming point is within a loop, this will create and return a copy of \p
714+
/// value inside \p inBlock.
711715
SILValue
712716
makeNewValueAvailable(SILValue value, SILBasicBlock *inBlock);
713717

714718
/// Given an ssa value \p value, create destroy_values at leaking blocks
719+
///
720+
/// Warning: This does not properly cleanup an OSSA lifetime with a consuming
721+
/// use blocks inside a loop relative to \p value. The client must create
722+
/// separate copies for any uses within the loop.
715723
void endLifetimeAtLeakingBlocks(SILValue value,
716724
ArrayRef<SILBasicBlock *> userBBs);
717725

lib/SILOptimizer/Utils/InstOptUtils.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,6 +2052,8 @@ bool swift::tryEliminateOnlyOwnershipUsedForwardingInst(
20522052
return true;
20532053
}
20542054

2055+
// The consuming use blocks are assumed either not to inside a loop relative to
2056+
// \p value or they must have their own copies.
20552057
void swift::endLifetimeAtLeakingBlocks(SILValue value,
20562058
ArrayRef<SILBasicBlock *> uses) {
20572059
if (!value->getFunction()->hasOwnership())

0 commit comments

Comments
 (0)