[all-commits] [llvm/llvm-project] c68ba1: [clang][modules] Mark fewer identifiers as out-of-...

Jan Svoboda via All-commits all-commits at lists.llvm.org
Tue Jul 4 03:58:59 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c68ba12abf490716fd7a57bba9c2dda1d537b19c
      https://github.com/llvm/llvm-project/commit/c68ba12abf490716fd7a57bba9c2dda1d537b19c
  Author: Jan Svoboda <jan_svoboda at apple.com>
  Date:   2023-07-04 (Tue, 04 Jul 2023)

  Changed paths:
    M clang/lib/Serialization/ASTReader.cpp
    M clang/lib/Serialization/ASTWriter.cpp

  Log Message:
  -----------
  [clang][modules] Mark fewer identifiers as out-of-date

In `clang-scan-deps` contexts, the number of interesting identifiers in PCM files is fairly low (only macros), while the number of identifiers in the importing instance is high (builtins). Marking the whole identifier table out-of-date triggers lots of benign and expensive calls to `ASTReader::updateOutOfDateIdentifiers()`. (That unfortunately happens even for unused identifiers due to `SemaRef.IdResolver.begin(II)` line in `ASTWriter::WriteASTCore()`.)

This patch makes the main code path more similar to C++ modules, where the PCM files have `INTERESTING_IDENTIFIERS` section which lists identifiers that get created in the identifier table of the importing instance and marked as out-of-date. The only difference is that the main code path doesn't *create* identifiers in the table and relies on the importing instance calling `ASTReader::get()` when creating new identifier on-demand. It only marks existing identifiers as out-of-date.

This speeds up `clang-scan-deps` by 5-10%.

Reviewed By: Bigcheese, benlangmuir

Differential Revision: https://reviews.llvm.org/D151277




More information about the All-commits mailing list