This is an archive of the discontinued LLVM Phabricator instance.

[mlir][IR] Hash nesting structure in OperationFingerPrint
ClosedPublic

Authored by springerm on May 24 2023, 1:34 AM.

Details

Summary

The following ops currently have the same finger print, even though they are different:

func.func @test() {
  "test.foo"() ({
    "test.bar"() : () -> ()
  }) : () -> ()
}

And:

func.func @test() {
  "test.bar"() : () -> ()
  "test.foo"() ({ }) : () -> ()
}

The SHA1 hash used in OperationFingerPrint is order-sensitive, but the ops are hashed in the same order (post-order traversal), so the hash is the same. Switching to pre-order traversal does not solve the issue; a similar example, where IR differs just in its nesting structure, can be constructed.

The problem is solved by hashing the parent op pointer. (Alternatively, a custom traversal over the IR that hashes scope markers ({}) could be used.)

Note: Without this change, the expensive check in D144552 detects a false positive in mlir/test/IR/greedy-pattern-rewriter-driver.mlir.

Diff Detail

Event Timeline

springerm created this revision.May 24 2023, 1:34 AM
Herald added a project: Restricted Project. · View Herald Transcript
springerm requested review of this revision.May 24 2023, 1:34 AM
springerm edited the summary of this revision. (Show Details)May 24 2023, 1:34 AM
springerm edited the summary of this revision. (Show Details)
mehdi_amini accepted this revision.May 24 2023, 2:03 AM
This revision is now accepted and ready to land.May 24 2023, 2:03 AM