[lld] [lld][WebAssembly] Improve error message on adding LTO object post-LTO. NFC (PR #66688)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 18 12:24:30 PDT 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lld-wasm
<details>
<summary>Changes</summary>
We have been getting errors from emscripten users where including the name of the symbol that triggered the inclusion would be useful in the diagnosis. e.g:
https://github.com/emscripten-core/emscripten/issues/20275
---
Full diff: https://github.com/llvm/llvm-project/pull/66688.diff
5 Files Affected:
- (modified) lld/test/wasm/lto/libcall-truncsfhf2.ll (+1-1)
- (modified) lld/wasm/InputFiles.cpp (+3-3)
- (modified) lld/wasm/InputFiles.h (+1-1)
- (modified) lld/wasm/SymbolTable.cpp (+2-2)
- (modified) lld/wasm/SymbolTable.h (+1-1)
``````````diff
diff --git a/lld/test/wasm/lto/libcall-truncsfhf2.ll b/lld/test/wasm/lto/libcall-truncsfhf2.ll
index 1eea2b28b6db1d8..08b334ace9ba30c 100644
--- a/lld/test/wasm/lto/libcall-truncsfhf2.ll
+++ b/lld/test/wasm/lto/libcall-truncsfhf2.ll
@@ -17,4 +17,4 @@ define void @_start() {
ret void
}
-; CHECK: wasm-ld: error: {{.*}}truncsfhf2.o): attempt to add bitcode file after LTO.
+; CHECK: wasm-ld: error: {{.*}}truncsfhf2.o): attempt to add bitcode file after LTO (__truncsfhf2)
diff --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp
index fa20a35ded9d9e6..96ac1e1610dd3b0 100644
--- a/lld/wasm/InputFiles.cpp
+++ b/lld/wasm/InputFiles.cpp
@@ -760,7 +760,7 @@ void ArchiveFile::addMember(const Archive::Symbol *sym) {
sym->getName());
InputFile *obj = createObjectFile(mb, getName(), c.getChildOffset());
- symtab->addFile(obj);
+ symtab->addFile(obj, sym->getName());
}
static uint8_t mapVisibility(GlobalValue::VisibilityTypes gvVisibility) {
@@ -826,9 +826,9 @@ BitcodeFile::BitcodeFile(MemoryBufferRef m, StringRef archiveName,
bool BitcodeFile::doneLTO = false;
-void BitcodeFile::parse() {
+void BitcodeFile::parse(StringRef symName) {
if (doneLTO) {
- error(toString(this) + ": attempt to add bitcode file after LTO.");
+ error(toString(this) + ": attempt to add bitcode file after LTO (" + symName + ")");
return;
}
diff --git a/lld/wasm/InputFiles.h b/lld/wasm/InputFiles.h
index 327813484eafd3a..d9a8b5306603249 100644
--- a/lld/wasm/InputFiles.h
+++ b/lld/wasm/InputFiles.h
@@ -176,7 +176,7 @@ class BitcodeFile : public InputFile {
uint64_t offsetInArchive);
static bool classof(const InputFile *f) { return f->kind() == BitcodeKind; }
- void parse();
+ void parse(StringRef symName);
std::unique_ptr<llvm::lto::InputFile> obj;
// Set to true once LTO is complete in order prevent further bitcode objects
diff --git a/lld/wasm/SymbolTable.cpp b/lld/wasm/SymbolTable.cpp
index d33176a0fa54ad6..9a381e95f3d9fa5 100644
--- a/lld/wasm/SymbolTable.cpp
+++ b/lld/wasm/SymbolTable.cpp
@@ -23,7 +23,7 @@ using namespace llvm::object;
namespace lld::wasm {
SymbolTable *symtab;
-void SymbolTable::addFile(InputFile *file) {
+void SymbolTable::addFile(InputFile *file, StringRef symName) {
log("Processing: " + toString(file));
// .a file
@@ -50,7 +50,7 @@ void SymbolTable::addFile(InputFile *file) {
// LLVM bitcode file
if (auto *f = dyn_cast<BitcodeFile>(file)) {
- f->parse();
+ f->parse(symName);
bitcodeFiles.push_back(f);
return;
}
diff --git a/lld/wasm/SymbolTable.h b/lld/wasm/SymbolTable.h
index ef2a023b68c44d8..59eda1c0b6740c2 100644
--- a/lld/wasm/SymbolTable.h
+++ b/lld/wasm/SymbolTable.h
@@ -40,7 +40,7 @@ class SymbolTable {
void wrap(Symbol *sym, Symbol *real, Symbol *wrap);
- void addFile(InputFile *file);
+ void addFile(InputFile *file, StringRef symName = {});
void compileBitcodeFiles();
``````````
</details>
https://github.com/llvm/llvm-project/pull/66688
More information about the llvm-commits
mailing list