[PATCH] D42327: [WebAssembly] Remove redundant function: addSyntheticUndefinedFunction
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 19 17:11:16 PST 2018
sbc100 created this revision.
Herald added subscribers: llvm-commits, sunfish, aheejin, jgravelle-google, dschuff, jfb.
Also, ensure addDefinedFunction() and addDefinedGlobal()
will overide any existing undefined symbol.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D42327
Files:
wasm/Driver.cpp
wasm/SymbolTable.cpp
Index: wasm/SymbolTable.cpp
===================================================================
--- wasm/SymbolTable.cpp
+++ wasm/SymbolTable.cpp
@@ -131,6 +131,9 @@
S->setFunctionType(Type);
} else if (!S->isFunction()) {
error("symbol type mismatch: " + Name);
+ } else if (!S->isDefined()) {
+ DEBUG(dbgs() << "resolving existing undefined function: " << Name << "\n");
+ S->update(Symbol::DefinedFunctionKind, nullptr, Flags);
}
return S;
}
@@ -140,10 +143,14 @@
Symbol *S;
bool WasInserted;
std::tie(S, WasInserted) = insert(Name);
- if (WasInserted)
+ if (WasInserted) {
S->update(Symbol::DefinedGlobalKind);
- else if (!S->isGlobal())
+ } else if (!S->isGlobal()) {
error("symbol type mismatch: " + Name);
+ } else {
+ DEBUG(dbgs() << "resolving existing undefined global: " << Name << "\n");
+ S->update(Symbol::DefinedGlobalKind);
+ }
return S;
}
@@ -187,6 +194,7 @@
Symbol *SymbolTable::addUndefinedFunction(StringRef Name,
const WasmSignature *Type) {
+ DEBUG(dbgs() << "addUndefinedFunction: " << Name << "\n");
Symbol *S;
bool WasInserted;
std::tie(S, WasInserted) = insert(Name);
Index: wasm/Driver.cpp
===================================================================
--- wasm/Driver.cpp
+++ wasm/Driver.cpp
@@ -134,14 +134,6 @@
return None;
}
-// Inject a new undefined symbol into the link. This will cause the link to
-// fail unless this symbol can be found.
-static void addSyntheticUndefinedFunction(StringRef Name,
- const WasmSignature *Type) {
- log("injecting undefined func: " + Name);
- Symtab->addUndefinedFunction(Name, Type);
-}
-
static void printHelp(const char *Argv0) {
WasmOptTable().PrintHelp(outs(), Argv0, "LLVM Linker", false);
}
@@ -293,11 +285,11 @@
if (!Config->Relocatable) {
static WasmSignature Signature = {{}, WASM_TYPE_NORESULT};
if (!Config->Entry.empty())
- addSyntheticUndefinedFunction(Config->Entry, &Signature);
+ Symtab->addUndefinedFunction(Config->Entry, &Signature);
// Handle the `--undefined <sym>` options.
for (auto* Arg : Args.filtered(OPT_undefined))
- addSyntheticUndefinedFunction(Arg->getValue(), nullptr);
+ Symtab->addUndefinedFunction(Arg->getValue(), nullptr);
// Create linker-synthetic symbols
// __wasm_call_ctors:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42327.130730.patch
Type: text/x-patch
Size: 2423 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180120/2dc78b9c/attachment.bin>
More information about the llvm-commits
mailing list