[all-commits] [llvm/llvm-project] 261b47: [FileCheck] Don't use regex to find prefixes (#72237)

Nikita Popov via All-commits all-commits at lists.llvm.org
Wed Nov 15 00:35:06 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 261b471015ef674253f03a4ae213919d983e016e
      https://github.com/llvm/llvm-project/commit/261b471015ef674253f03a4ae213919d983e016e
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2023-11-15 (Wed, 15 Nov 2023)

  Changed paths:
    M llvm/include/llvm/FileCheck/FileCheck.h
    M llvm/lib/FileCheck/FileCheck.cpp
    M llvm/unittests/CodeGen/GlobalISel/GISelMITest.h
    M llvm/unittests/MIR/MachineMetadata.cpp
    M llvm/utils/FileCheck/FileCheck.cpp

  Log Message:
  -----------
  [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.




More information about the All-commits mailing list