[lld][ELF] Add --why-extract for bitcode libcalls#78781
Merged
Conversation
Member
|
@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();
}
}
|
Member
|
Can you add test? You can add |
Member
|
ping for a test |
Collaborator
Author
|
Sorry, I dropping this completely.. picking it up now. |
Collaborator
Author
|
Test added |
MaskRay
reviewed
Mar 26, 2024
MaskRay
approved these changes
Mar 26, 2024
MaskRay
reviewed
Mar 26, 2024
The Wasm linker already records these and its seems useful to do so.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Wasm linker already records these and its seems useful to do so.