From 3876d89a1b28bdcfaa0b2e658e56cc22f9970348 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 14 May 2018 22:42:33 +0000 Subject: [PATCH] [WebAssembly] Update to match llvm changes Subscribers: dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D46849 llvm-svn: 332306 --- lld/test/wasm/symbol-type-mismatch.ll | 4 ++-- lld/wasm/SymbolTable.cpp | 12 ++++++------ lld/wasm/Symbols.cpp | 22 ++++------------------ lld/wasm/Symbols.h | 1 - 4 files changed, 12 insertions(+), 27 deletions(-) diff --git a/lld/test/wasm/symbol-type-mismatch.ll b/lld/test/wasm/symbol-type-mismatch.ll index b38a219..4738c4b 100644 --- a/lld/test/wasm/symbol-type-mismatch.ll +++ b/lld/test/wasm/symbol-type-mismatch.ll @@ -7,5 +7,5 @@ target triple = "wasm32-unknown-unknown" @ret32 = extern_weak global i32, align 4 ; CHECK: error: symbol type mismatch: ret32 -; CHECK: >>> defined as Data in {{.*}}symbol-type-mismatch.ll.tmp.o -; CHECK: >>> defined as Function in {{.*}}.ret32.o +; CHECK: >>> defined as WASM_SYMBOL_TYPE_DATA in {{.*}}symbol-type-mismatch.ll.tmp.o +; CHECK: >>> defined as WASM_SYMBOL_TYPE_FUNCTION in {{.*}}.ret32.o diff --git a/lld/wasm/SymbolTable.cpp b/lld/wasm/SymbolTable.cpp index 54e04ab..e86d82f 100644 --- a/lld/wasm/SymbolTable.cpp +++ b/lld/wasm/SymbolTable.cpp @@ -69,17 +69,17 @@ std::pair SymbolTable::insert(StringRef Name) { } static void reportTypeError(const Symbol *Existing, const InputFile *File, - StringRef Type) { + llvm::wasm::WasmSymbolType Type) { error("symbol type mismatch: " + toString(*Existing) + "\n>>> defined as " + toString(Existing->getWasmType()) + " in " + - toString(Existing->getFile()) + "\n>>> defined as " + Type + " in " + - toString(File)); + toString(Existing->getFile()) + "\n>>> defined as " + toString(Type) + + " in " + toString(File)); } static void checkFunctionType(const Symbol *Existing, const InputFile *File, const WasmSignature *NewSig) { if (!isa(Existing)) { - reportTypeError(Existing, File, "Function"); + reportTypeError(Existing, File, WASM_SYMBOL_TYPE_FUNCTION); return; } @@ -98,7 +98,7 @@ static void checkFunctionType(const Symbol *Existing, const InputFile *File, static void checkGlobalType(const Symbol *Existing, const InputFile *File, const WasmGlobalType *NewType) { if (!isa(Existing)) { - reportTypeError(Existing, File, "Global"); + reportTypeError(Existing, File, WASM_SYMBOL_TYPE_GLOBAL); return; } @@ -112,7 +112,7 @@ static void checkGlobalType(const Symbol *Existing, const InputFile *File, static void checkDataType(const Symbol *Existing, const InputFile *File) { if (!isa(Existing)) - reportTypeError(Existing, File, "Data"); + reportTypeError(Existing, File, WASM_SYMBOL_TYPE_DATA); } DefinedFunction *SymbolTable::addSyntheticFunction(StringRef Name, diff --git a/lld/wasm/Symbols.cpp b/lld/wasm/Symbols.cpp index 1139e26..82310c4 100644 --- a/lld/wasm/Symbols.cpp +++ b/lld/wasm/Symbols.cpp @@ -31,13 +31,13 @@ DefinedGlobal *WasmSym::StackPointer; WasmSymbolType Symbol::getWasmType() const { if (isa(this)) - return llvm::wasm::WASM_SYMBOL_TYPE_FUNCTION; + return WASM_SYMBOL_TYPE_FUNCTION; if (isa(this)) - return llvm::wasm::WASM_SYMBOL_TYPE_DATA; + return WASM_SYMBOL_TYPE_DATA; if (isa(this)) - return llvm::wasm::WASM_SYMBOL_TYPE_GLOBAL; + return WASM_SYMBOL_TYPE_GLOBAL; if (isa(this)) - return llvm::wasm::WASM_SYMBOL_TYPE_SECTION; + return WASM_SYMBOL_TYPE_SECTION; llvm_unreachable("invalid symbol kind"); } @@ -239,17 +239,3 @@ std::string lld::toString(wasm::Symbol::Kind Kind) { } llvm_unreachable("invalid symbol kind"); } - -std::string lld::toString(WasmSymbolType Type) { - switch (Type) { - case llvm::wasm::WASM_SYMBOL_TYPE_FUNCTION: - return "Function"; - case llvm::wasm::WASM_SYMBOL_TYPE_DATA: - return "Data"; - case llvm::wasm::WASM_SYMBOL_TYPE_GLOBAL: - return "Global"; - case llvm::wasm::WASM_SYMBOL_TYPE_SECTION: - return "Section"; - } - llvm_unreachable("invalid symbol type"); -} diff --git a/lld/wasm/Symbols.h b/lld/wasm/Symbols.h index 0fa599f..8556d32 100644 --- a/lld/wasm/Symbols.h +++ b/lld/wasm/Symbols.h @@ -340,7 +340,6 @@ T *replaceSymbol(Symbol *S, ArgT &&... Arg) { // Returns a symbol name for an error message. std::string toString(const wasm::Symbol &Sym); std::string toString(wasm::Symbol::Kind Kind); -std::string toString(WasmSymbolType Type); } // namespace lld -- 2.7.4