llvm.org GIT mirror llvm / c494412
[Docs] Fix post-review comments on MemorySSA's docs. Thanks to Sean Silva for bringing these up. :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278885 91177308-0d34-0410-b5e6-96231b3b80d8 George Burgess IV 3 years ago
1 changed file(s) with 10 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
109109 br label %if.end
110110
111111 if.end:
112 ; 5 = MemoryPhi({if.then,2},{if.then,3})
112 ; 5 = MemoryPhi({if.then,2},{if.else,3})
113113 ; MemoryUse(5)
114114 %1 = load i8, i8* %p1
115115 ; 4 = MemoryDef(5)
119119 br label %while.cond
120120 }
121121
122 The ``MemorySSA`` IR is located comments that precede the instructions they map
122 The ``MemorySSA`` IR is shown in comments that precede the instructions they map
123123 to (if such an instruction exists). For example, ``1 = MemoryDef(liveOnEntry)``
124124 is a ``MemoryAccess`` (specifically, a ``MemoryDef``), and it describes the LLVM
125125 instruction ``store i8 0, i8* %p3``. Other places in ``MemorySSA`` refer to this
129129
130130 Going from the top down:
131131
132 - ``6 = MemoryPhi({%0,1},{if.end,4})`` notes that, when entering ``while.cond``,
133 the reaching definition for it is either ``1`` or ``4``. This ``MemoryPhi`` is
134 referred to in the textual IR by the number ``6``.
132 - ``6 = MemoryPhi({entry,1},{if.end,4})`` notes that, when entering
133 ``while.cond``, the reaching definition for it is either ``1`` or ``4``. This
134 ``MemoryPhi`` is referred to in the textual IR by the number ``6``.
135135 - ``2 = MemoryDef(6)`` notes that ``store i8 0, i8* %p1`` is a definition,
136136 and its reaching definition before it is ``6``, or the ``MemoryPhi`` after
137137 ``while.cond``.
138138 - ``3 = MemoryDef(6)`` notes that ``store i8 0, i8* %p2`` is a definition; its
139139 reaching definition is also ``6``.
140 - ``5 = MemoryPhi({if.then,2},{if.then,3})`` notes that the clobber before
140 - ``5 = MemoryPhi({if.then,2},{if.else,3})`` notes that the clobber before
141141 this block could either be ``2`` or ``3``.
142142 - ``MemoryUse(5)`` notes that ``load i8, i8* %p1`` is a use of memory, and that
143143 it's clobbered by ``5``.
211211 ----------------
212212
213213 ``MemorySSA`` will optimize some ``MemoryAccess`` es at build-time.
214 Specifically, we optimize the operand of every ``MemoryUse`` s to point to the
214 Specifically, we optimize the operand of every ``MemoryUse`` to point to the
215215 actual clobber of said ``MemoryUse``. This can be seen in the above example; the
216216 second ``MemoryUse`` in ``if.end`` has an operand of ``1``, which is a
217217 ``MemoryDef`` from the entry block. This is done to make walking,
226226
227227 Because ``MemorySSA`` keeps track of LLVM IR, it needs to be updated whenever
228228 the IR is updated. "Update", in this case, includes the addition, deletion, and
229 motion of IR instructions. The update API is being made on an as-needed basis.
229 motion of ``Instructions``. The update API is being made on an as-needed basis.
230 If you'd like examples, ``GVNHoist`` is a user of ``MemorySSA`` s update API.
230231
231232
232233 Phi placement
311312
312313 Precision
313314 ^^^^^^^^^
315
314316 ``MemorySSA`` in LLVM deliberately trades off precision for speed.
315317 Let us think about memory variables as if they were disjoint partitions of the
316318 heap (that is, if you have one variable, as above, it represents the entire