[PATCH] D128318: [pseudo] prototype: faster data structures for LRTable

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 21 19:20:04 PDT 2022


sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added a subscriber: mgrang.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, alextsao1999.
Herald added a project: clang-tools-extra.

For shift and goto, use a hashtable for faster lookups. This is ~3x bigger,
but these are not most of the actions (~15% each).

For reduce, the common pattern is that a (state, reduce rule) pair applies to
lots of possible lookahead tokens. So store this as one object with a bitmap for
the valid lookahead tokens. This is very efficient (~4x smaller than before).

Overall we're <20% bigger which seems acceptable.
Before: size of the table (bytes): 401554
After: size of the table (bytes): 470636 (Shift=196608 Reduce=77284 Goto=196608)

This yields a 24% speedup of glrParse on my machine (3.5 -> 4.35 MB/s)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128318

Files:
  clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
  clang-tools-extra/pseudo/lib/GLR.cpp
  clang-tools-extra/pseudo/lib/grammar/LRTable.cpp
  clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128318.438890.patch
Type: text/x-patch
Size: 13742 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220622/b1ccf9ff/attachment.bin>


More information about the cfe-commits mailing list