[PATCH] D134942: [Lex] Simplify and cleanup the updateConsecutiveMacroArgTokens implementation.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 30 02:26:12 PDT 2022


hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: All.
hokein requested review of this revision.
Herald added a project: clang.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134942

Files:
  clang/lib/Lex/TokenLexer.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134942.464188.patch
Type: text/x-patch
Size: 4809 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220930/fe4f62f7/attachment.bin>


More information about the cfe-commits mailing list