[Mlir-commits] [mlir] [mlir][IR] `OperationFingerPrint`: Fix block hashing (PR #78255)

Matthias Springer llvmlistbot at llvm.org
Tue Jan 16 02:50:58 PST 2024


https://github.com/matthias-springer created https://github.com/llvm/llvm-project/pull/78255

Two blocks can be equivalent even though their allocated `Block *` do not match. Therefore, they should not be taken into account when computing an operation finger print. (This is consistent with `OperationEquivalence`, which also does not compare `Block *`.)

Furthermore, in addition to operation locations, block argument location should also be hashed. (Block argument locations can differ from operation locations.)

>From 91524590f1acd3daa54dcbd827c0d00542fc5cd1 Mon Sep 17 00:00:00 2001
From: Matthias Springer <springerm at google.com>
Date: Tue, 16 Jan 2024 10:46:33 +0000
Subject: [PATCH] [mlir][IR] `OperationFingerPrint`: Fix block hashing

Two blocks can be equivalent even though their allocated `Block *` do not match. Therefore, it should not be taken into account when computing an operation finger print. (This is consistent with `OperationEquivalence`, which also does not compare `Block *`.)

Furthermore, in addition to operation locations, block argument location should also be hashed. (Block argument locations can differ from operation locations.)
---
 mlir/lib/IR/OperationSupport.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mlir/lib/IR/OperationSupport.cpp b/mlir/lib/IR/OperationSupport.cpp
index e10cd748e03ba5..c76dc4e8f3d949 100644
--- a/mlir/lib/IR/OperationSupport.cpp
+++ b/mlir/lib/IR/OperationSupport.cpp
@@ -928,9 +928,10 @@ OperationFingerPrint::OperationFingerPrint(Operation *topOp) {
     //   - Blocks in Regions
     for (Region &region : op->getRegions()) {
       for (Block &block : region) {
-        addDataToHash(hasher, &block);
-        for (BlockArgument arg : block.getArguments())
+        for (BlockArgument arg : block.getArguments()) {
           addDataToHash(hasher, arg);
+          addDataToHash(hasher, arg.getLoc().getAsOpaquePointer());
+        }
       }
     }
     //   - Location



More information about the Mlir-commits mailing list