Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spirv: deduplication pass #19490

Merged
merged 5 commits into from
Apr 1, 2024
Merged

spirv: deduplication pass #19490

merged 5 commits into from
Apr 1, 2024

Conversation

Snektron
Copy link
Collaborator

This linker pass deduplicates types and constants which are the same. It works by hashing and comparing the type/constant/annotation trees (of which a node is called an "entity"), and checking if all the members are the same.

To hash a type or compare two types, their trees are recursively walked and each node is hashed or compared. This is not done with anything smart for now, because we need to mind to handle recursive types in a way that yields the same hash for different types that have the same recursive structure. Recursive types are handled by storing all pointers in an ArrayHashMap, and if the pointer is already there (and so this is a recursive type), the index is hashed or compared instead of recursively processing it. For two equal types, these recursive pointers will have the same indices. This might seem like it would yield false positives, but in those cases there would also be a different type structure (for instance, an extra struct node in the tree), which is caught by the regular comparison code.

For some related yap on the linker, see the previous merge request, #19337

@Snektron Snektron marked this pull request as ready for review March 30, 2024 22:12
@Snektron Snektron merged commit d2be725 into ziglang:master Apr 1, 2024
10 checks passed
@Snektron Snektron deleted the spirv-dedup branch April 1, 2024 07:51
@Snektron Snektron mentioned this pull request Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant