summaryrefslogtreecommitdiffstats
path: root/lld/wasm/SymbolTable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/wasm/SymbolTable.cpp')
-rw-r--r--lld/wasm/SymbolTable.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/lld/wasm/SymbolTable.cpp b/lld/wasm/SymbolTable.cpp
index 1180cfc6759..6541ddcdb87 100644
--- a/lld/wasm/SymbolTable.cpp
+++ b/lld/wasm/SymbolTable.cpp
@@ -106,7 +106,7 @@ static void reportTypeError(const Symbol *Existing, const InputFile *File,
" in " + toString(File));
}
-static void checkFunctionType(const Symbol *Existing, const InputFile *File,
+static void checkFunctionType(Symbol *Existing, const InputFile *File,
const WasmSignature *NewSig) {
auto ExistingFunction = dyn_cast<FunctionSymbol>(Existing);
if (!ExistingFunction) {
@@ -114,13 +114,20 @@ static void checkFunctionType(const Symbol *Existing, const InputFile *File,
return;
}
- const WasmSignature *OldSig = ExistingFunction->getFunctionType();
- if (OldSig && NewSig && *NewSig != *OldSig) {
+ if (!NewSig)
+ return;
+
+ const WasmSignature *OldSig = ExistingFunction->FunctionType;
+ if (!OldSig) {
+ ExistingFunction->FunctionType = NewSig;
+ return;
+ }
+
+ if (*NewSig != *OldSig)
warn("function signature mismatch: " + Existing->getName() +
"\n>>> defined as " + toString(*OldSig) + " in " +
toString(Existing->getFile()) + "\n>>> defined as " +
toString(*NewSig) + " in " + toString(File));
- }
}
// Check the type of new symbol matches that of the symbol is replacing.
@@ -286,8 +293,9 @@ Symbol *SymbolTable::addUndefinedFunction(StringRef Name, uint32_t Flags,
replaceSymbol<UndefinedFunction>(S, Name, Flags, File, Sig);
else if (auto *Lazy = dyn_cast<LazySymbol>(S))
Lazy->fetch();
- else if (S->isDefined())
+ else
checkFunctionType(S, File, Sig);
+
return S;
}
OpenPOWER on IntegriCloud