[all-commits] [llvm/llvm-project] 6040e2: [Support] Add GlobPattern::isTrivialMatchAll()

Andrew Ng via All-commits all-commits at lists.llvm.org
Wed Sep 16 02:27:59 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 6040e2a6d97d9f9445715dfc468c3112f40e2588
      https://github.com/llvm/llvm-project/commit/6040e2a6d97d9f9445715dfc468c3112f40e2588
  Author: Andrew Ng <andrew.ng at sony.com>
  Date:   2020-09-16 (Wed, 16 Sep 2020)

  Changed paths:
    M llvm/include/llvm/Support/GlobPattern.h
    M llvm/unittests/Support/GlobPatternTest.cpp

  Log Message:
  -----------
  [Support] Add GlobPattern::isTrivialMatchAll()

GlobPattern::isTrivialMatchAll() returns true for the GlobPattern "*"
which will match all inputs.

This can be used to avoid performing expensive preparation of the input
for match() when the result of the match will always be true.

Differential Revision: https://reviews.llvm.org/D87468


  Commit: 77152a6b7ac07ce65568d7c69305653e7cad4bb0
      https://github.com/llvm/llvm-project/commit/77152a6b7ac07ce65568d7c69305653e7cad4bb0
  Author: Andrew Ng <andrew.ng at sony.com>
  Date:   2020-09-16 (Wed, 16 Sep 2020)

  Changed paths:
    M lld/ELF/AArch64ErrataFix.h
    M lld/ELF/ARMErrataFix.h
    M lld/ELF/InputFiles.cpp
    M lld/ELF/InputFiles.h
    M lld/ELF/LinkerScript.cpp
    M lld/ELF/LinkerScript.h
    M lld/ELF/Relocations.h
    M lld/include/lld/Common/Strings.h

  Log Message:
  -----------
  [LLD][ELF] Optimize linker script filename glob pattern matching NFC

Optimize the filename glob pattern matching in
LinkerScript::computeInputSections() and LinkerScript::shouldKeep().

Add InputFile::getNameForScript() which gets and if required caches the
Inputfile's name used for linker script matching. This avoids the
overhead of name creation that was in getFilename() in LinkerScript.cpp.

Add InputSectionDescription::matchesFile() and
SectionPattern::excludesFile() which perform the glob pattern matching
for an InputFile and make use of a cache of the previous result. As both
computeInputSections() and shouldKeep() process sections in order and
the sections of the same InputFile are contiguous, these single entry
caches can significantly speed up performance for more complex glob
patterns.

These changes have been seen to reduce link time with --gc-sections by
up to ~40% with linker scripts that contain KEEP filename glob patterns
such as "*crtbegin*.o".

Differential Revision: https://reviews.llvm.org/D87469


Compare: https://github.com/llvm/llvm-project/compare/3a0a2a6347f5...77152a6b7ac0


More information about the All-commits mailing list