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

Canonicalize types based on hashing than HirIds and TyTy equality #1265

Merged
merged 1 commit into from May 23, 2022

Conversation

philberty
Copy link
Member

This patch updates how we canonicalize the types. The old method was not
able to handle more complex cases involving generic associated types. So
this now uses a moe generic hashing system which now speeds up the lookups.

The commit message gives much more detail here.

@philberty philberty added this to the Imports and visibility milestone May 20, 2022
@philberty philberty added this to In progress in Imports and Visbility via automation May 20, 2022
@philberty philberty self-assigned this May 20, 2022
When we compile types for GCC we need to make sure we canonicalize them,
this means that for any user defined type such as Structs or Tuples we want
all expressions or declarations to use the same tree. Even if we have
duplicate tree's we can end up confusing the middle-end and lose out on
optimizations as we will be using view_convert_exprs to maintain the
consistancy which will marshall between the objects unnessecarily.

The old method for doing this kept mappings of HirIds which was fine for
simple cases but when generics are involved new Id's are generated so this
meant we ended up having a vector of pairs {TyTy::BaseType, tree} and we
did a liner search to find the relevant TyTy::BaseType that we equaled to.

This was not only slow but did not handle the cases for generic associated
types or nested generics. So we needed a more general faster implementation
therefore hashing. This patch takes the gcc/tree.h type_hash_canon code
and adds in hashing for RECORD and UNION types. This means we will generate
a duplicate type then hash it and look for an existing type.

This patch will also allow us to fix how we implement monomorphization of
functions by nesting the hashes behind DefId's.
@philberty
Copy link
Member Author

bors r+

@bors
Copy link
Contributor

bors bot commented May 23, 2022

Build succeeded:

@bors bors bot merged commit 55ec345 into master May 23, 2022
Imports and Visbility automation moved this from In progress to Done May 23, 2022
@philberty philberty deleted the phil/canonicalization branch May 23, 2022 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

1 participant