aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2022-04-14 11:49:35 +0200
committerNikita Popov <npopov@redhat.com>2022-04-19 09:55:21 +0200
commit653de14f17215c540a7dc058acb3c29a28ef0f1c (patch)
tree53344043b0a28e8e2b033048d8203b3236527133 /clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
parenta3005a406e195bf8e9798cdf4173fdadabac49bb (diff)
downloadllvm-653de14f17215c540a7dc058acb3c29a28ef0f1c.zip
llvm-653de14f17215c540a7dc058acb3c29a28ef0f1c.tar.gz
llvm-653de14f17215c540a7dc058acb3c29a28ef0f1c.tar.bz2
[Support] Optimize (.*) regex matches
If capturing groups are used, the regex matcher handles something like `(.*)suffix` by first doing a maximal match of `.*`, trying to match `suffix` afterward, and then reducing the maximal stop position one by one until this finally succeeds. This makes the match quadratic in the length of the line (with large constant factors). This is particularly problematic because regexes of this form are ubiquitous in FileCheck (something like `[[VAR:%.*]] = ...` falls in this category), making FileCheck executions much slower than they have any right to be. This implements a very crude optimization that checks if suffix starts with a fixed character, and steps back to the last occurrence of that character, instead of stepping back by one character at a time. This drops FileCheck time on clang/test/CodeGen/RISCV/rvv-intrinsics/vloxseg_mask.c from 7.3 seconds to 2.7 seconds. An obvious further improvement would be to check more than one character (once again, this is particularly relevant for FileCheck, because the next character is usually a space, which happens to have many occurrences). This should help with https://github.com/llvm/llvm-project/issues/54821.
Diffstat (limited to 'clang/lib/Frontend/CreateInvocationFromCommandLine.cpp')
0 files changed, 0 insertions, 0 deletions