Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TableGen] Fix prefix detection with anchor (NFC) #71379

Merged
merged 1 commit into from
Nov 13, 2023

Conversation

nikic
Copy link
Contributor

@nikic nikic commented Nov 6, 2023

instregex uses an optimization, where the constant prefix of the regex is extracted to perform a binary search first. However, this optimization currently mainly fails to apply, because most instregex uses have an explicit ^ anchor, which gets counted as a meta char and disables the optimization.

Make sure the anchor is skipped when determining the prefix. Also fix an implementation bug this exposes, where the pick a too long prefix if the first meta character is a quantifier.

This cuts the time needed to generate files like X86GenInstrInfo.inc by half.

instregex uses an optimization, where the constant prefix of the
regex is extracted to perform a binary search first. However,
this optimization currently mainly fails to apply, because most
instregex uses have an explicit ^ anchor, which gets counted as
a meta char and disables the optimization.

Make sure the anchor is skipped when determining the prefix. Also
fix an implementation bug this exposes, where the pick a too long
prefix if the first meta character is a quantifier.

This cuts the time needed to generate files like X86GenInstrInfo.inc
by half.
@nikic nikic requested review from RKSimon and topperc November 6, 2023 11:09
@nikic
Copy link
Contributor Author

nikic commented Nov 13, 2023

ping

Copy link
Collaborator

@RKSimon RKSimon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nikic nikic merged commit 0a0e06f into llvm:main Nov 13, 2023
3 checks passed
zahiraam pushed a commit to zahiraam/llvm-project that referenced this pull request Nov 20, 2023
instregex uses an optimization, where the constant prefix of the regex
is extracted to perform a binary search first. However, this
optimization currently mainly fails to apply, because most instregex
uses have an explicit ^ anchor, which gets counted as a meta char and
disables the optimization.

Make sure the anchor is skipped when determining the prefix. Also fix an
implementation bug this exposes, where the pick a too long prefix if the
first meta character is a quantifier.

This cuts the time needed to generate files like X86GenInstrInfo.inc by
half.
Guzhu-AMD pushed a commit to GPUOpen-Drivers/llvm-project that referenced this pull request Nov 23, 2023
Local branch amd-gfx 4810346 Merged main:01893b54835b into amd-gfx:d6fa9f734aa3
Remote branch main 0a0e06f [TableGen] Fix prefix detection with anchor (NFC) (llvm#71379)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants