[lld] [lld][ELF] Add `--why-extract` for bitcode libcalls (PR #78781)
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 19 12:59:00 PST 2024
https://github.com/sbc100 updated https://github.com/llvm/llvm-project/pull/78781
>From 084def0c8b67142f2acc9f9296cb9ac481dde011 Mon Sep 17 00:00:00 2001
From: Sam Clegg <sbc at chromium.org>
Date: Fri, 19 Jan 2024 20:45:16 +0000
Subject: [PATCH] [lld][ELF] Add `--why-extract` for bitcode libcalls
The Wasm linker already records these and its seems useful to do
so.
---
lld/ELF/Driver.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
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() {
More information about the llvm-commits
mailing list