diff options
author | Nikita Popov <npopov@redhat.com> | 2023-11-15 09:34:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-15 09:34:52 +0100 |
commit | 261b471015ef674253f03a4ae213919d983e016e (patch) | |
tree | b279c784d710685f78c0efdcaa610311b816d9cd /llvm/utils/FileCheck/FileCheck.cpp | |
parent | 9a9933fae23249fbf6cf5b3c090e630f578b7f98 (diff) | |
download | llvm-261b471015ef674253f03a4ae213919d983e016e.zip llvm-261b471015ef674253f03a4ae213919d983e016e.tar.gz llvm-261b471015ef674253f03a4ae213919d983e016e.tar.bz2 |
[FileCheck] Don't use regex to find prefixes (#72237)
FileCheck currently compiles a regular expression of the form
`Prefix1|Prefix2|...` and uses it to find the next prefix in the input.
If we had a fast regex implementation, this would be a useful thing to
do, as the regex implementation would be able to match multiple prefixes
more efficiently than a naive approach. However, with our actual regex
implementation, finding the prefixes basically becomes O(InputLen *
RegexLen * LargeConstantFactor), which is a lot worse than a simple
string search.
Replace the regex with StringRef::find(), and keeping track of the next
position of each prefix. There are various ways this could be improved
on, but it's already significantly faster that the previous approach.
For me, this improves check-llvm time from 138.5s to 132.5s, so by
around 4-5%.
For vector-interleaved-load-i16-stride-7.ll in particular, test time
drops from 5s to 2.5s.
Diffstat (limited to 'llvm/utils/FileCheck/FileCheck.cpp')
-rw-r--r-- | llvm/utils/FileCheck/FileCheck.cpp | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/llvm/utils/FileCheck/FileCheck.cpp b/llvm/utils/FileCheck/FileCheck.cpp index 5f85f4f..e74a79e 100644 --- a/llvm/utils/FileCheck/FileCheck.cpp +++ b/llvm/utils/FileCheck/FileCheck.cpp @@ -810,17 +810,6 @@ int main(int argc, char **argv) { if (!FC.ValidateCheckPrefixes()) return 2; - Regex PrefixRE = FC.buildCheckPrefixRegex(); - std::string REError; - if (!PrefixRE.isValid(REError)) { - errs() << "Unable to combine check-prefix strings into a prefix regular " - "expression! This is likely a bug in FileCheck's verification of " - "the check-prefix strings. Regular expression parsing failed " - "with the following error: " - << REError << "\n"; - return 2; - } - SourceMgr SM; // Read the expected strings from the check file. @@ -842,7 +831,7 @@ int main(int argc, char **argv) { SMLoc()); std::pair<unsigned, unsigned> ImpPatBufferIDRange; - if (FC.readCheckFile(SM, CheckFileText, PrefixRE, &ImpPatBufferIDRange)) + if (FC.readCheckFile(SM, CheckFileText, &ImpPatBufferIDRange)) return 2; // Open the file to check and add it to SourceMgr. |