Index: wasm/Driver.cpp =================================================================== --- wasm/Driver.cpp +++ wasm/Driver.cpp @@ -31,6 +31,7 @@ #define DEBUG_TYPE "lld" using namespace llvm; +using namespace llvm::object; using namespace llvm::sys; using namespace llvm::wasm; Index: wasm/InputChunks.h =================================================================== --- wasm/InputChunks.h +++ wasm/InputChunks.h @@ -24,18 +24,9 @@ #include "Config.h" #include "InputFiles.h" #include "lld/Common/ErrorHandler.h" +#include "lld/Common/LLVM.h" #include "llvm/Object/Wasm.h" -using llvm::object::WasmSection; -using llvm::object::WasmSegment; -using llvm::wasm::WasmFunction; -using llvm::wasm::WasmRelocation; -using llvm::wasm::WasmSignature; - -namespace llvm { -class raw_ostream; -} - namespace lld { namespace wasm { @@ -53,8 +44,13 @@ virtual void writeTo(uint8_t *SectionStart) const; - ArrayRef getRelocations() const { return Relocations; } - void setRelocations(ArrayRef Rs) { Relocations = Rs; } + ArrayRef getRelocations() const { + return Relocations; + } + + void setRelocations(ArrayRef Relocs) { + Relocations = Relocs; + } virtual StringRef getName() const = 0; virtual StringRef getDebugName() const = 0; @@ -83,7 +79,7 @@ // This is performed only debug builds as an extra sanity check. void verifyRelocTargets() const; - ArrayRef Relocations; + ArrayRef Relocations; Kind SectionKind; }; @@ -97,7 +93,7 @@ // each global variable. class InputSegment : public InputChunk { public: - InputSegment(const WasmSegment &Seg, ObjFile *F) + InputSegment(const llvm::object::WasmSegment &Seg, ObjFile *F) : InputChunk(F, InputChunk::DataSegment), Segment(Seg) {} static bool classof(const InputChunk *C) { return C->kind() == DataSegment; } @@ -116,14 +112,15 @@ protected: ArrayRef data() const override { return Segment.Data.Content; } - const WasmSegment &Segment; + const llvm::object::WasmSegment &Segment; }; // Represents a single wasm function within and input file. These are // combined to create the final output CODE section. class InputFunction : public InputChunk { public: - InputFunction(const WasmSignature &S, const WasmFunction *Func, ObjFile *F) + InputFunction(const llvm::wasm::WasmSignature &S, + const llvm::wasm::WasmFunction *Func, ObjFile *F) : InputChunk(F, InputChunk::Function), Signature(S), Function(Func) {} static bool classof(const InputChunk *C) { @@ -161,7 +158,7 @@ // called. void calculateSize(); - const WasmSignature &Signature; + const llvm::wasm::WasmSignature &Signature; protected: ArrayRef data() const override { @@ -170,7 +167,7 @@ Function->Size); } - const WasmFunction *Function; + const llvm::wasm::WasmFunction *Function; llvm::Optional FunctionIndex; llvm::Optional TableIndex; uint32_t CompressedFuncSize = 0; @@ -179,7 +176,7 @@ class SyntheticFunction : public InputFunction { public: - SyntheticFunction(const WasmSignature &S, StringRef Name, + SyntheticFunction(const llvm::wasm::WasmSignature &S, StringRef Name, StringRef DebugName = {}) : InputFunction(S, nullptr, nullptr), Name(Name), DebugName(DebugName) { SectionKind = InputChunk::SyntheticFunction; @@ -206,7 +203,7 @@ // Represents a single Wasm Section within an input file. class InputSection : public InputChunk { public: - InputSection(const WasmSection &S, ObjFile *F) + InputSection(const llvm::object::WasmSection &S, ObjFile *F) : InputChunk(F, InputChunk::Section), Section(S) { assert(Section.Type == llvm::wasm::WASM_SEC_CUSTOM); } @@ -222,7 +219,7 @@ // type represents an entire input section, not part of one. uint32_t getInputSectionOffset() const override { return 0; } - const WasmSection &Section; + const llvm::object::WasmSection &Section; }; } // namespace wasm Index: wasm/InputFiles.h =================================================================== --- wasm/InputFiles.h +++ wasm/InputFiles.h @@ -20,21 +20,6 @@ #include "llvm/Support/MemoryBuffer.h" #include -using llvm::object::Archive; -using llvm::object::WasmObjectFile; -using llvm::object::WasmSection; -using llvm::object::WasmSymbol; -using llvm::wasm::WasmGlobal; -using llvm::wasm::WasmImport; -using llvm::wasm::WasmRelocation; -using llvm::wasm::WasmSignature; - -namespace llvm { -namespace lto { -class InputFile; -} -} // namespace llvm - namespace lld { namespace wasm { @@ -84,12 +69,12 @@ explicit ArchiveFile(MemoryBufferRef M) : InputFile(ArchiveKind, M) {} static bool classof(const InputFile *F) { return F->kind() == ArchiveKind; } - void addMember(const Archive::Symbol *Sym); + void addMember(const llvm::object::Archive::Symbol *Sym); void parse() override; private: - std::unique_ptr File; + std::unique_ptr File; llvm::DenseSet Seen; }; @@ -102,17 +87,19 @@ void parse() override; // Returns the underlying wasm file. - const WasmObjectFile *getWasmObj() const { return WasmObj.get(); } + const llvm::object::WasmObjectFile *getWasmObj() const { + return WasmObj.get(); + } void dumpInfo() const; - uint32_t calcNewIndex(const WasmRelocation &Reloc) const; - uint32_t calcNewValue(const WasmRelocation &Reloc) const; - uint32_t calcNewAddend(const WasmRelocation &Reloc) const; - uint32_t calcExpectedValue(const WasmRelocation &Reloc) const; + uint32_t calcNewIndex(const llvm::wasm::WasmRelocation &Reloc) const; + uint32_t calcNewValue(const llvm::wasm::WasmRelocation &Reloc) const; + uint32_t calcNewAddend(const llvm::wasm::WasmRelocation &Reloc) const; + uint32_t calcExpectedValue(const llvm::wasm::WasmRelocation &Reloc) const; - const WasmSection *CodeSection = nullptr; - const WasmSection *DataSection = nullptr; + const llvm::object::WasmSection *CodeSection = nullptr; + const llvm::object::WasmSection *DataSection = nullptr; // Maps input type indices to output type indices std::vector TypeMap; @@ -133,12 +120,12 @@ SectionSymbol *getSectionSymbol(uint32_t Index) const; private: - Symbol *createDefined(const WasmSymbol &Sym); - Symbol *createUndefined(const WasmSymbol &Sym); + Symbol *createDefined(const llvm::object::WasmSymbol &Sym); + Symbol *createUndefined(const llvm::object::WasmSymbol &Sym); bool isExcludedByComdat(InputChunk *Chunk) const; - std::unique_ptr WasmObj; + std::unique_ptr WasmObj; }; class BitcodeFile : public InputFile { Index: wasm/InputGlobal.h =================================================================== --- wasm/InputGlobal.h +++ wasm/InputGlobal.h @@ -16,9 +16,6 @@ #include "lld/Common/ErrorHandler.h" #include "llvm/Object/Wasm.h" -using llvm::wasm::WasmGlobal; -using llvm::wasm::WasmInitExpr; - namespace lld { namespace wasm { @@ -26,11 +23,11 @@ // combined to form the final GLOBALS section. class InputGlobal { public: - InputGlobal(const WasmGlobal &G, ObjFile *F) + InputGlobal(const llvm::wasm::WasmGlobal &G, ObjFile *F) : File(F), Global(G), Live(!Config->GcSections) {} StringRef getName() const { return Global.SymbolName; } - const WasmGlobalType &getType() const { return Global.Type; } + const llvm::wasm::WasmGlobalType &getType() const { return Global.Type; } uint32_t getGlobalIndex() const { return GlobalIndex.getValue(); } bool hasGlobalIndex() const { return GlobalIndex.hasValue(); } @@ -40,7 +37,7 @@ } ObjFile *File; - WasmGlobal Global; + llvm::wasm::WasmGlobal Global; bool Live = false; Index: wasm/OutputSections.h =================================================================== --- wasm/OutputSections.h +++ wasm/OutputSections.h @@ -13,11 +13,9 @@ #include "InputChunks.h" #include "WriterUtils.h" #include "lld/Common/ErrorHandler.h" +#include "lld/Common/LLVM.h" #include "llvm/ADT/DenseMap.h" -using llvm::raw_ostream; -using llvm::raw_string_ostream; - namespace lld { namespace wasm { @@ -82,7 +80,7 @@ std::string Body; protected: - raw_string_ostream BodyOutputStream; + llvm::raw_string_ostream BodyOutputStream; }; class CodeSection : public OutputSection { Index: wasm/SymbolTable.h =================================================================== --- wasm/SymbolTable.h +++ wasm/SymbolTable.h @@ -15,10 +15,13 @@ #include "Symbols.h" #include "llvm/ADT/CachedHashString.h" #include "llvm/ADT/DenseSet.h" -#include "llvm/Support/raw_ostream.h" -using llvm::wasm::WasmGlobalType; -using llvm::wasm::WasmSignature; +namespace llvm { +namespace wasm { +struct WasmGlobalType; +struct WasmSignature; +} +} namespace lld { namespace wasm { @@ -61,12 +64,12 @@ InputGlobal *G); Symbol *addUndefinedFunction(StringRef Name, uint32_t Flags, InputFile *File, - const WasmSignature *Signature); + const llvm::wasm::WasmSignature *Signature); Symbol *addUndefinedData(StringRef Name, uint32_t Flags, InputFile *File); Symbol *addUndefinedGlobal(StringRef Name, uint32_t Flags, InputFile *File, - const WasmGlobalType *Type); + const llvm::wasm::WasmGlobalType *Type); - void addLazy(ArchiveFile *F, const Archive::Symbol *Sym); + void addLazy(ArchiveFile *F, const llvm::object::Archive::Symbol *Sym); bool addComdat(StringRef Name); Index: wasm/SymbolTable.cpp =================================================================== --- wasm/SymbolTable.cpp +++ wasm/SymbolTable.cpp @@ -20,6 +20,7 @@ using namespace llvm; using namespace llvm::wasm; +using namespace llvm::object; using namespace lld; using namespace lld::wasm; Index: wasm/Symbols.h =================================================================== --- wasm/Symbols.h +++ wasm/Symbols.h @@ -15,13 +15,6 @@ #include "llvm/Object/Archive.h" #include "llvm/Object/Wasm.h" -using llvm::object::Archive; -using llvm::object::WasmSymbol; -using llvm::wasm::WasmGlobal; -using llvm::wasm::WasmGlobalType; -using llvm::wasm::WasmSignature; -using llvm::wasm::WasmSymbolType; - namespace lld { namespace wasm { @@ -89,7 +82,7 @@ uint32_t getOutputSymbolIndex() const; void setOutputSymbolIndex(uint32_t Index); - WasmSymbolType getWasmType() const; + llvm::wasm::WasmSymbolType getWasmType() const; bool isExported() const; // True if this symbol was referenced by a regular (non-bitcode) object. @@ -126,11 +119,11 @@ void setFunctionIndex(uint32_t Index); bool hasFunctionIndex() const; - const WasmSignature *FunctionType; + const llvm::wasm::WasmSignature *FunctionType; protected: FunctionSymbol(StringRef Name, Kind K, uint32_t Flags, InputFile *F, - const WasmSignature *Type) + const llvm::wasm::WasmSignature *Type) : Symbol(Name, K, Flags, F), FunctionType(Type) {} uint32_t TableIndex = INVALID_INDEX; @@ -152,7 +145,7 @@ class UndefinedFunction : public FunctionSymbol { public: UndefinedFunction(StringRef Name, uint32_t Flags, InputFile *File = nullptr, - const WasmSignature *Type = nullptr) + const llvm::wasm::WasmSignature *Type = nullptr) : FunctionSymbol(Name, UndefinedFunctionKind, Flags, File, Type) {} static bool classof(const Symbol *S) { @@ -233,7 +226,7 @@ return S->kind() == DefinedGlobalKind || S->kind() == UndefinedGlobalKind; } - const WasmGlobalType *getGlobalType() const { return GlobalType; } + const llvm::wasm::WasmGlobalType *getGlobalType() const { return GlobalType; } // Get/set the global index uint32_t getGlobalIndex() const; @@ -242,12 +235,12 @@ protected: GlobalSymbol(StringRef Name, Kind K, uint32_t Flags, InputFile *F, - const WasmGlobalType *GlobalType) + const llvm::wasm::WasmGlobalType *GlobalType) : Symbol(Name, K, Flags, F), GlobalType(GlobalType) {} // Explicit function type, needed for undefined or synthetic functions only. // For regular defined globals this information comes from the InputChunk. - const WasmGlobalType *GlobalType; + const llvm::wasm::WasmGlobalType *GlobalType; uint32_t GlobalIndex = INVALID_INDEX; }; @@ -266,7 +259,7 @@ class UndefinedGlobal : public GlobalSymbol { public: UndefinedGlobal(StringRef Name, uint32_t Flags, InputFile *File = nullptr, - const WasmGlobalType *Type = nullptr) + const llvm::wasm::WasmGlobalType *Type = nullptr) : GlobalSymbol(Name, UndefinedGlobalKind, Flags, File, Type) {} static bool classof(const Symbol *S) { @@ -276,14 +269,15 @@ class LazySymbol : public Symbol { public: - LazySymbol(StringRef Name, InputFile *File, const Archive::Symbol &Sym) + LazySymbol(StringRef Name, InputFile *File, + const llvm::object::Archive::Symbol &Sym) : Symbol(Name, LazyKind, 0, File), ArchiveSymbol(Sym) {} static bool classof(const Symbol *S) { return S->kind() == LazyKind; } void fetch(); private: - Archive::Symbol ArchiveSymbol; + llvm::object::Archive::Symbol ArchiveSymbol; }; // linker-generated symbols Index: wasm/WriterUtils.h =================================================================== --- wasm/WriterUtils.h +++ wasm/WriterUtils.h @@ -13,9 +13,6 @@ #include "lld/Common/LLVM.h" #include "llvm/ADT/Twine.h" #include "llvm/Object/Wasm.h" -#include "llvm/Support/raw_ostream.h" - -using llvm::raw_ostream; namespace lld { namespace wasm {