Skip to content

Commit 78dbe2b

Browse files
committed
Add a comment to ValueLifetimeBoundary
Explaining a footgun that I've forgotten to check for more than once.
1 parent d0443be commit 78dbe2b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

include/swift/SILOptimizer/Utils/ValueLifetime.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ namespace swift {
3737
/// Frontier implementation by adding a utility method that populates a vector
3838
/// of insertion points based on this boundary, where each each
3939
/// block-terminating lastUser adds an insertion point at each successor block.
40+
///
41+
/// Note: A dead live range will have no last users and no boundary
42+
/// edges. Always check if the definition passed to ValueLifetimeAnalysis is
43+
/// dead before assuming that this boundary covers all points at which a value
44+
/// must be destroyed. Normally, a live range with uses will have at least one
45+
/// lastUser or boundaryEdge. But with infinite loops, it is possible for both
46+
/// lastUsers and boundaryEdges to be empty even if there are uses within the
47+
/// loop.
4048
struct ValueLifetimeBoundary {
4149
SmallVector<SILInstruction *, 8> lastUsers;
4250
SmallVector<SILBasicBlock *, 8> boundaryEdges;

0 commit comments

Comments
 (0)