[all-commits] [llvm/llvm-project] 74e4f7: [Lex] Simplify and cleanup the updateConsecutiveMa...

Haojian Wu via All-commits all-commits at lists.llvm.org
Fri Oct 7 00:16:36 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 74e4f778cf16cbf7163b5c6de6027a43f5e9169f
      https://github.com/llvm/llvm-project/commit/74e4f778cf16cbf7163b5c6de6027a43f5e9169f
  Author: Haojian Wu <hokein.wu at gmail.com>
  Date:   2022-10-07 (Fri, 07 Oct 2022)

  Changed paths:
    M clang/lib/Lex/TokenLexer.cpp

  Log Message:
  -----------
  [Lex] Simplify and cleanup the updateConsecutiveMacroArgTokens implementation.

The code falls back to the pre-2011 partition-file-id solution (see for
[details](https://reviews.llvm.org/D20401#3823476)).

This patch simplifies/rewrites the code based on the partition-based-on-file-id
idea. The new implementation is optimized by reducing the number of
calling getFileID (~40% drop).

Despite the huge drop of getFileID, this is a marignal improvment on
speed (becase the number of calling non-cached getFileID is roughly
the same). It removes the evaluation-order performance gap between gcc-built-clang
and clang-built-clang.

SemaExpr.cpp:
- before: 315063 SLocEntries, FileID scans: 388230 linear, 1393437 binary. 458893 cache hits, 672299 getFileID calls
- after:  313494 SLocEntries, FileID scans: 397525 linear, 1451890 binary, 176714 cache hits, 397144 getFileID calls

FindTarget.cpp:
- before: 279984 SLocEntries, FileID scans: 361926 linear, 1275930 binary, 436072 cache hits, 632150 getFileID calls
- after:  278426 SLocEntries, FileID scans: 371279 linear, 1333963 binary, 153705 cache hits, 356814 getFileID calls

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




More information about the All-commits mailing list