Repository navigation
Constant arrays and tuples are named from their content, not from attribute addresses - #819
Merged
Merged
Conversation
…ribute addresses
calc_hash_value combined hash_value of the elements' attributes, which hashes their
addresses with a weak mix: [1, 2] and [3, 4] were named about 1200 apart, the names
changed from run to run, and a collision gave one constant array another's data
(00owned_iteration failed once on wasm32 rc debug, a rebuild passed). The name is now
an xxh3 hash of the type and elements as MLIR prints them, and an array's size is
kept apart from it ("a_2" + "11..." was "a_21" + "1...").
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Constant arrays (
a_…) and constant tuples (tp_…) are now named from their content, not from where their MLIR attributes happen to sit in memory.The bug
calc_hash_valuecombinedhash_valueof the type and of each element attribute. MLIR hashes an attribute or a type by its address, with a weak mix. So:[1, 2]and[3, 4]were about 1,200 apart (a_211972185937195vsa_211972185936021)."a_2"+"11…"and"a_21"+"1…"spell the same name.A global with a given name is shared by every constant that gets that name. So a collision gives one constant array another's data, and how often that happens depends on the addresses of a run. This is the likely cause of the one unexplained failure in #818's testing:
00owned_iteration.ts(wasm32, rc, debug) failed an assertion, the same way in all 5 runs of that build, and a rebuild passed.The fix
xxh3_64bitshash of the type and the elements as MLIR prints them, so identical constants still share a global.a_<size>_<hash>).Checks
00owned_iteration.tsgives the samea_/tp_names. Its[1, 2],[2, 3]and[3, 4]now get unrelated hashes.[1, 2]in two functions shares one global, with the same name it gets in another file.[2, 1]against[1, 2], all get distinct names, and the program prints the right values.Not changed
Other names still come from
hash_valueof a type: the type descriptortd_, the release/retain/share routinestsrel_/tsret_/tsshr_, and object-literal class names such asShape.136163259. Each of those hashes one type's address rather than combining several, so a collision is much less likely, but it is possible, and those names also vary between runs. Because they differ from run to run, two builds of the same program aren't byte-identical.🤖 Generated with Claude Code