[Mlir-commits] [mlir] becc238 - [mlir][docs] Fix mistakes in data flow analysis code example (#97286)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Jul 1 10:00:02 PDT 2024


Author: Matthias Springer
Date: 2024-07-01T18:59:58+02:00
New Revision: becc238f77ee2b95b5cdfc2d060fe6ff5b6e447d

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

LOG: [mlir][docs] Fix mistakes in data flow analysis code example (#97286)

Added: 
    

Modified: 
    mlir/docs/Tutorials/DataFlowAnalysis.md

Removed: 
    


################################################################################
diff  --git a/mlir/docs/Tutorials/DataFlowAnalysis.md b/mlir/docs/Tutorials/DataFlowAnalysis.md
index 8265eff8b6ec7..ea7158fb7391d 100644
--- a/mlir/docs/Tutorials/DataFlowAnalysis.md
+++ b/mlir/docs/Tutorials/DataFlowAnalysis.md
@@ -114,10 +114,10 @@ struct MetadataLatticeValue {
     // only keep information that is the same. This means that we only keep
     // facts that are true in both.
     MetadataLatticeValue result;
-    for (const auto &lhsIt : lhs) {
+    for (const auto &lhsIt : lhs.metadata) {
       // As noted above, we only merge if the values are the same.
       auto it = rhs.metadata.find(lhsIt.first);
-      if (it == rhs.metadata.end() || it->second != lhsIt.second)
+      if (it == rhs.metadata.end() || it.second != lhsIt.second)
         continue;
       result.insert(lhsIt);
     }
@@ -129,10 +129,13 @@ struct MetadataLatticeValue {
   bool operator==(const MetadataLatticeValue &rhs) const {
     if (metadata.size() != rhs.metadata.size())
       return false;
-    // Check that the 'rhs' contains the same metadata.
-    return llvm::all_of(metadata, [&](auto &it) {
-      return rhs.metadata.count(it.second);
-    });
+    // Check that `rhs` contains the same metadata.
+    for (const auto &it : metadata) {
+      auto rhsIt = rhs.metadata.find(it.first);
+      if (rhsIt == rhs.metadata.end() || it.second != rhsIt.second)
+        return false;
+    }
+    return true;
   }
 
   /// Our value represents the combined metadata, which is originally a


        


More information about the Mlir-commits mailing list