[Mlir-commits] [mlir] [mlir] [dataflow] avoid hash collisions (PR #191188)

donald chen llvmlistbot at llvm.org
Tue May 26 00:45:44 PDT 2026


https://github.com/cxy-1993 updated https://github.com/llvm/llvm-project/pull/191188

>From 17735925e47c85e23e4a27b76ec397ba2d8c1095 Mon Sep 17 00:00:00 2001
From: donald <chenxunyu1993 at gmail.com>
Date: Thu, 9 Apr 2026 12:49:50 +0000
Subject: [PATCH] [mlir] [dataflow] avoid hash collisions

This patch fixes potential hash collisions when using ProgramPoint
as a DenseMap key. For program points without a parent block, the
Operation* should be used to compute the hash value.
---
 mlir/include/mlir/Analysis/DataFlowFramework.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mlir/include/mlir/Analysis/DataFlowFramework.h b/mlir/include/mlir/Analysis/DataFlowFramework.h
index 87ec01a918d90..8aa57f3bb6690 100644
--- a/mlir/include/mlir/Analysis/DataFlowFramework.h
+++ b/mlir/include/mlir/Analysis/DataFlowFramework.h
@@ -798,6 +798,8 @@ struct DenseMapInfo<mlir::ProgramPoint> {
         mlir::Block::iterator((mlir::Operation *)pointer));
   }
   static unsigned getHashValue(mlir::ProgramPoint pp) {
+    if (mlir::Operation *op = pp.getOperation())
+      return hash_value(op);
     return hash_combine(pp.getBlock(), pp.getPoint().getNodePtr());
   }
   static bool isEqual(mlir::ProgramPoint lhs, mlir::ProgramPoint rhs) {
@@ -805,7 +807,7 @@ struct DenseMapInfo<mlir::ProgramPoint> {
   }
 };
 
-// Allow llvm::cast style functions.
+/// Allow llvm::cast style functions.
 template <typename To>
 struct CastInfo<To, mlir::LatticeAnchor>
     : public CastInfo<To, mlir::LatticeAnchor::PointerUnion> {};



More information about the Mlir-commits mailing list