This allows operations and values to be used as dict keys
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Bindings/Python/IRCore.cpp | ||
---|---|---|
2175 | Let's use llvm::hash_value that has the desirable properties of hash values instead of blindly reusing the pointer. Also, please prefer C++ static_cast to C-style casts in C++ code. |
mlir/test/python/ir/operation.py | ||
---|---|---|
754 | I don't think hashes are guaranteed to be different. They happen to be because they are currently pointer addresses. |
mlir/lib/Bindings/Python/IRCore.cpp | ||
---|---|---|
2175 | Should I update the hash functions for PyType and PyAttribute this way as well? Also I noticed that there's llvm::hash_value overloads for Value, Type, and Attribute (but not Operation) defined already, should I thread those through the C bindings and use them here? Or is it sufficient to just hash the pointers that are currently being returned? |
mlir/lib/Bindings/Python/IRCore.cpp | ||
---|---|---|
2175 | I went with hashing the pointers in here for now, and also updated PyType and PyAttribute to do this as well. | |
mlir/test/python/ir/operation.py | ||
754 | I removed all the tests that checked for hashes being different, since pointer addresses are no longer being used directly. |
Let's hash pointers for now, my primary concern was the loss of hash function properties that defies the purpose of hash tables. FYI, there's no llvm::hash_value overload for Operation because we never use operations by value, only by pointer, and LLVM already knows how to hash pointers.
Let's use llvm::hash_value that has the desirable properties of hash values instead of blindly reusing the pointer. Also, please prefer C++ static_cast to C-style casts in C++ code.