Skip to content

Commit 2a6c662

Browse files
authored
Merge pull request #75702 from gottesmm/pr-1804290685c6f10ea751b04a00b27057b5a5f6f4
[region-isolation] Add a comment to VariableNamePathArray that explains its "snapshot" functionality and why it is useful.
2 parents 454dfb9 + d8d4989 commit 2a6c662

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

include/swift/SILOptimizer/Utils/VariableNameUtils.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,26 @@ class VariableNameInferrer {
4141
using Options = OptionSet<Flag>;
4242

4343
private:
44-
template <typename T, unsigned smallSize>
44+
/// A two phase stack data structure. The first phase only allows for two
45+
/// operations:
46+
///
47+
/// 1. pushing elements onto the stack.
48+
/// 2. pushing/popping a "snapshot" of the stack (see description below).
49+
///
50+
/// The second phase only allows for the stack to be drained.
51+
///
52+
/// DISCUSSION: The snapshot operation stashes the current size of the
53+
/// variable name path array when the snapshot operation occurs. If one pops
54+
/// the snapshot, the data structure sets its current insertion point to be
55+
/// the old stack point effectively popping off all of the elements of the
56+
/// stack until the last snapshot. This is useful when working with things
57+
/// like phis where one wants to speculatively push items onto this stack
58+
/// while discovering if one has an actual interesting value from the phi. If
59+
/// one fails to find something interesting, then one can just pop the
60+
/// snapshot and go process the next phi incoming value.
61+
template <typename T, unsigned SmallSize>
4562
class VariableNamePathArray {
46-
SmallVector<T, smallSize> data;
63+
SmallVector<T, SmallSize> data;
4764

4865
unsigned lastSnapShotIndex = 0;
4966
unsigned insertionPointIndex = 0;

0 commit comments

Comments
 (0)