-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lld][ELF] Add --why-extract
for bitcode libcalls
#78781
Conversation
@llvm/pr-subscribers-lld @llvm/pr-subscribers-lld-wasm Author: Sam Clegg (sbc100) ChangesThe Wasm linker already records these and its seems useful to do so. Also mirror the simplications of this function from # in the Wasm linker #78659. Full diff: https://github.com/llvm/llvm-project/pull/78781.diff 2 Files Affected:
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 07f4263c90e62b3..6e9b6ba6a2476b1 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -2081,8 +2081,11 @@ static void handleUndefinedGlob(StringRef arg) {
static void handleLibcall(StringRef name) {
Symbol *sym = symtab.find(name);
- if (sym && sym->isLazy() && isa<BitcodeFile>(sym->file))
+ if (sym && sym->isLazy() && isa<BitcodeFile>(sym->file)) {
+ if (!config->whyExtract.empty())
+ ctx.whyExtractRecords.emplace_back("<libcall>", sym->file, *sym);
sym->extract();
+ }
}
static void writeArchiveStats() {
diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index 4a4f9a96227946d..862d095dc105184 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -716,16 +716,10 @@ static Symbol *handleUndefined(StringRef name, const char *option) {
static void handleLibcall(StringRef name) {
Symbol *sym = symtab->find(name);
- if (!sym)
- return;
-
- if (auto *lazySym = dyn_cast<LazySymbol>(sym)) {
- MemoryBufferRef mb = lazySym->getMemberBuffer();
- if (isBitcode(mb)) {
- if (!config->whyExtract.empty())
- ctx.whyExtractRecords.emplace_back("<libcall>", sym->getFile(), *sym);
- lazySym->extract();
- }
+ if (sym && sym->isLazy() && isa<BitcodeFile>(sym->file)) {
+ if (!config->whyExtract.empty())
+ ctx.whyExtractRecords.emplace_back("<libcall>", sym->getFile(), *sym);
+ lazySym->extract();
}
}
|
Can you add test? You can add |
ping for a test |
Sorry, I dropping this completely.. picking it up now. |
Test added |
The Wasm linker already records these and its seems useful to do so.
The Wasm linker already records these and its seems useful to do so.