[PATCH] D87469: [LLD][ELF] Optimize linker script filename glob pattern matching NFC
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 14 02:10:58 PDT 2020
grimar accepted this revision.
grimar added a comment.
This revision is now accepted and ready to land.
LGTM. Please wait for @MaskRay opinion.
================
Comment at: lld/ELF/LinkerScript.cpp:324
+static StringRef getFilename(const InputFile *file) {
+ return file ? file->getNameForScript() : StringRef();
+}
----------------
andrewng wrote:
> grimar wrote:
> > It feels that `getFilename` can instead be just inlined now, though?
> I've inlined the function.
I've meant it is a single line function and you can probably just remove it and inline its logic.
E.g:
```
if (!matchesFileCache || matchesFileCache->first != file)
matchesFileCache.emplace(
file, filePat.match(getFilename(file ? file->getNameForScript() : "")));
```
Up to you.
A bit unrelated to this diff: thinking more I wonder if we want to assume an empty file name at all for matching.
We perhaps can be more explicit. Something like:
```
bool InputSectionDescription::matchesFile(const InputFile *file) const {
if (filePat.isTrivialMatchAll())
return true;
if (!file)
return false;
...
```
```
bool SectionPattern::excludesFile(const InputFile *file) const {
if (!file || excludedFilePat.empty())
return false;
...
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87469/new/
https://reviews.llvm.org/D87469
More information about the llvm-commits
mailing list