@@ -69,6 +69,53 @@ namespace swift {
69
69
// / a place-holder value and updating the map entry. This works because the
70
70
// / value storage map holds no direct references to any SIL entities, such as
71
71
// / Operands or SILValues.
72
+ // /
73
+ // / An opaque value's storage will be a def-projection if it's the result of
74
+ // / some disaggregation. If %o = disaggregate %p then %o's storage will be
75
+ // / a def-projection out of %p's storage.
76
+ // /
77
+ // / An opaque value's storage _may_ be a use-projection if it's an operand of
78
+ // / some aggregation. If %p = aggregate %o, then %o's storage may be a
79
+ // / use-projection out of %p's storage.
80
+ // /
81
+ // / Projections naturally form chains. A value's storage may be a projection
82
+ // / out of the storage of some other value's storage which is itself a
83
+ // / projection out of a third value's storage. This can happen in three ways:
84
+ // /
85
+ // / (1) %o -def-> %p -def-> %q
86
+ // / %p = disaggregate %q
87
+ // / %o = disaggregate %p
88
+ // / (2) %o -use-> %p -use-> %q
89
+ // / %p = aggregate %o
90
+ // / %q = aggregate %p
91
+ // / (3) %o -def-> %p -use-> %q
92
+ // / %p = ...
93
+ // / cond_br left, right
94
+ // / left:
95
+ // / %o = disaggregate %p
96
+ // / right:
97
+ // / %q = aggregate %p
98
+ // /
99
+ // / Branching like this is actually necessary. It's not legal to aggregate
100
+ // / guaranteed opaque values since doing so changes representation which
101
+ // / implies a copy.
102
+ // /
103
+ // / It is NOT possible to have links like
104
+ // /
105
+ // / (4) %o -use-> %p -def-> %q
106
+ // /
107
+ // / The reason is that the links mean contradictory things:
108
+ // / %o -use-> %p means %p = aggregate %o
109
+ // / %p -def-> %q means %p = disaggregate %q
110
+ // / There is no overlap between the "aggregate" and the "disaggregate"
111
+ // / opcodes.
112
+ // /
113
+ // / This means that any chain of projections looks like
114
+ // /
115
+ // / %d_0 -def-> ... -def-> %d_N -use-> %u_0 -use-> ... -use-> %u_M
116
+ // /
117
+ // / a sequence (possibly empty) of def projections followed by a sequence
118
+ // / (possibly emtpy) of use projections [projection_chain_structure].
72
119
struct ValueStorage {
73
120
enum : uint32_t { InvalidID = uint32_t (~0 ) };
74
121
enum : uint16_t { InvalidOper = uint16_t (~0 ) };
0 commit comments