forked from OSchip/llvm-project
[ELF] Improve --export-dynamic-symbol performance by checking whether wildcard is really used
A hasWildcard pattern iterates over symVector, which can be slow when there are many --export-dynamic-symbol. In optimistic cases, most patterns don't use a wildcard character. hasWildcard: false can avoid a symbol table iteration. While here, add two tests using `[` and `?`, respectively.
This commit is contained in:
parent
7ee758d691
commit
49279ca160
|
@ -1188,7 +1188,8 @@ static void readConfigs(opt::InputArgList &args) {
|
|||
// -Bsymbolic-functions (if STT_FUNC), --dynamic-list.
|
||||
for (auto *arg : args.filtered(OPT_export_dynamic_symbol))
|
||||
config->dynamicList.push_back(
|
||||
{arg->getValue(), /*isExternCpp=*/false, /*hasWildcard=*/true});
|
||||
{arg->getValue(), /*isExternCpp=*/false,
|
||||
/*hasWildcard=*/hasWildcard(arg->getValue())});
|
||||
|
||||
for (auto *arg : args.filtered(OPT_version_script))
|
||||
if (Optional<std::string> path = searchScript(arg->getValue())) {
|
||||
|
|
|
@ -1474,7 +1474,7 @@ void ScriptParser::readVersionDeclaration(StringRef verStr) {
|
|||
expect(";");
|
||||
}
|
||||
|
||||
static bool hasWildcard(StringRef s) {
|
||||
bool elf::hasWildcard(StringRef s) {
|
||||
return s.find_first_of("?*[") != StringRef::npos;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ void readDynamicList(MemoryBufferRef mb);
|
|||
// Parses the defsym expression.
|
||||
void readDefsym(StringRef name, MemoryBufferRef mb);
|
||||
|
||||
bool hasWildcard(StringRef s);
|
||||
|
||||
} // namespace elf
|
||||
} // namespace lld
|
||||
|
||||
|
|
|
@ -41,8 +41,12 @@
|
|||
# RUN: llvm-objdump -d %t.preempt3 | FileCheck --check-prefix=PLT %s
|
||||
|
||||
## The option value is a glob.
|
||||
# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol 'f*' %t.o -o %t.preempt4
|
||||
# RUN: llvm-objdump -d %t.preempt4 | FileCheck --check-prefix=PLT %s
|
||||
# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol 'f*' %t.o -o - | \
|
||||
# RUN: llvm-objdump -d - | FileCheck --check-prefix=PLT %s
|
||||
# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol '[f]o[o]' %t.o -o - | \
|
||||
# RUN: llvm-objdump -d - | FileCheck --check-prefix=PLT %s
|
||||
# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol 'f?o' %t.o -o - | \
|
||||
# RUN: llvm-objdump -d - | FileCheck --check-prefix=PLT %s
|
||||
|
||||
# PLT: <foo@plt>
|
||||
# NOPLT-NOT: <foo@plt>
|
||||
|
|
Loading…
Reference in New Issue