[all-commits] [llvm/llvm-project] c184b9: [C++20] [Modules] Write ODRHash for decls in GMF

Chuanqi Xu via All-commits all-commits at lists.llvm.org
Wed Jul 17 20:44:34 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c184b94ff6546c8ba8ac54b5127189427567978f
      https://github.com/llvm/llvm-project/commit/c184b94ff6546c8ba8ac54b5127189427567978f
  Author: Chuanqi Xu <yedeng.yd at linux.alibaba.com>
  Date:   2024-07-18 (Thu, 18 Jul 2024)

  Changed paths:
    M clang/lib/Serialization/ASTReaderDecl.cpp
    M clang/lib/Serialization/ASTWriter.cpp
    M clang/lib/Serialization/ASTWriterDecl.cpp

  Log Message:
  -----------
  [C++20] [Modules] Write ODRHash for decls in GMF

Previously, we skipped calculating ODRHash for decls in GMF when writing
them to .pcm files as an optimization. But actually, it is not
true that this will be a pure optimization. Whether or not it is
beneficial depends on the use cases. For example, if we're writing a
function `a` in module and there are 10 consumers of `a` in other TUs,
then the other TUs will pay for the cost to calculate the ODR hash for
`a` ten times. Then this optimization doesn't work. However, if all the
consumers of the module didn't touch `a`, then we can save the cost to
calculate the ODR hash of `a` for 1 times.

And the assumption to make it was: generally, the consumers of a module
may only consume a small part of the imported module. This is the reason
why we tried to load declarations, types and identifiers lazily. Then it
looks good to do the similar thing for calculating ODR hashs.

It works fine for a long time, until we started to look into the support
of modules in clangd. Then we meet multiple issue reports complaining
we're calculating ODR hash in the wrong place. To workaround these issue
reports, I decided to always write the ODRhash for decls in GMF. In my
local test, I only observed less than 1% compile time regression after
doing this. So it should be fine.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list