[llvm-branch-commits] [clang] [Serialization] Code cleanups and polish 83233 (PR #83237)

Chuanqi Xu via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Jul 10 02:52:03 PDT 2024


ChuanqiXu9 wrote:

@vgvassilev In the newest version, I introduced a new hasher TemplateArgumentHasher and use this new hasher to calculate the hash value for template arguments. We thought this may be harder. But I just realized, we don't have to provide a very precise results at first. Since we are only required to give the same hash value for the same template arguments, but not required to give different hash value for different template arguments. So technically, it will still be a correct implementation if we return the same value for all template arguments.

So I introduced a bail out mechanism in the new hasher: https://github.com/llvm/llvm-project/pull/83237/files#diff-211ba0dca7d2f4bd0555dcfe173edd4658b9b4e045c49cb851b47654891c1627R32-R33 which will return the default value  when it encounters the cases it can't handle.

It is safer and it is easier to maintain. We don't need to worry about the changes in ODRHash breaks the LazySpecializations. And we can improve it step by step. Although the performance, **theoretically**, may not be good as your first patch, I don't feel this is a problem. We can improve it later.

https://github.com/llvm/llvm-project/pull/83237


More information about the llvm-branch-commits mailing list