Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: Fix C++ examples in MemorySSA documentation #92802

Merged
merged 3 commits into from
May 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions llvm/docs/MemorySSA.rst
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ A code snippet for such a walk looks like this:
.. code-block:: c++

MemoryDef *Def; // find who's optimized or defining for this MemoryDef
for (auto& U : Def->uses()) {
MemoryAccess *MA = cast<MemoryAccess>(Use.getUser());
if (auto *DefUser = cast_of_null<MemoryDef>MA)
for (auto &U : Def->uses()) {
MemoryAccess *MA = cast<MemoryAccess>(U.getUser());
if (auto *DefUser = dyn_cast<MemoryDef>(MA))
if (DefUser->isOptimized() && DefUser->getOptimized() == Def) {
// User who is optimized to Def
} else {
Expand All @@ -312,19 +312,18 @@ the store.
.. code-block:: c++

checkUses(MemoryAccess *Def) { // Def can be a MemoryDef or a MemoryPhi.
for (auto& U : Def->uses()) {
MemoryAccess *MA = cast<MemoryAccess>(Use.getUser());
if (auto *MU = cast_of_null<MemoryUse>MA) {
for (auto &U : Def->uses()) {
MemoryAccess *MA = cast<MemoryAccess>(U.getUser());
if (auto *MU = dyn_cast<MemoryUse>(MA)) {
// Process MemoryUse as needed.
}
else {
} else {
// Process MemoryDef or MemoryPhi as needed.

// As a user can come up twice, as an optimized access and defining
// access, keep a visited list.

// Check transitive uses as needed
checkUses (MA); // use a worklist for an iterative algorithm
checkUses(MA); // use a worklist for an iterative algorithm
}
}
}
Expand Down
Loading