Skip to content

Commit 256c07d

Browse files
authored
Merge pull request swiftlang#35432 from gottesmm/pr-7fb67d1fbc179c64a49248476574d361bcd4ae0c
[sil] Improve comment on swift::replaceSingleUse.
2 parents 01efa2e + 2b73378 commit 256c07d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

include/swift/SILOptimizer/Utils/InstOptUtils.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,18 @@ SILBasicBlock::iterator replaceAllUsesAndErase(SingleValueInstruction *svi,
673673
SILValue newValue,
674674
InstModCallbacks &callbacks);
675675

676-
/// Low level routine that replaces the current value of \p use with \p
677-
/// newValue.
676+
/// This API is equivalent to performing \p use->set(\p newValue) except that:
677+
///
678+
/// 1. If the user of \p use is an end scope, this API no-opts. This API is only
679+
/// used in contexts where we are rewriting uses and are not interesting in
680+
/// end scope instructions since we are moving uses from one scope to another
681+
/// scope.
682+
///
683+
/// 2. If the user of \p use is not an end scope, but is a lifetime ending use
684+
/// of \p use->get(), we insert a destroy_value|end_borrow as appropriate on
685+
/// \p use->get() to ensure \p use->get()'s lifetime is still ended. We
686+
/// assume that if \p use->getUser() is lifetime ending, that our caller has
687+
/// ensured that we can end \p newValue's lifetime.
678688
SILBasicBlock::iterator replaceSingleUse(Operand *use, SILValue newValue,
679689
InstModCallbacks &callbacks);
680690

0 commit comments

Comments
 (0)