[llvm] 56a1f0a - Documentation: Fix C++ examples in MemorySSA documentation (#92802)

via llvm-commits llvm-commits at lists.llvm.org
Mon May 20 23:47:21 PDT 2024


Author: Yuxuan Chen
Date: 2024-05-20T23:47:17-07:00
New Revision: 56a1f0a022f6d7f6908af0df9e2e0567d5e4712e

URL: https://github.com/llvm/llvm-project/commit/56a1f0a022f6d7f6908af0df9e2e0567d5e4712e
DIFF: https://github.com/llvm/llvm-project/commit/56a1f0a022f6d7f6908af0df9e2e0567d5e4712e.diff

LOG: Documentation: Fix C++ examples in MemorySSA documentation (#92802)

Added: 
    

Modified: 
    llvm/docs/MemorySSA.rst

Removed: 
    


################################################################################
diff  --git a/llvm/docs/MemorySSA.rst b/llvm/docs/MemorySSA.rst
index 17d2c9af96c23..09e9f9a377327 100644
--- a/llvm/docs/MemorySSA.rst
+++ b/llvm/docs/MemorySSA.rst
@@ -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 {
@@ -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
       }
     }
   }


        


More information about the llvm-commits mailing list