Index: COFF/Driver.h =================================================================== --- COFF/Driver.h +++ COFF/Driver.h @@ -36,10 +36,10 @@ using llvm::Optional; // Implemented in MarkLive.cpp. -void markLive(const std::vector &Chunks); +void markLive(ArrayRef Chunks); // Implemented in ICF.cpp. -void doICF(const std::vector &Chunks); +void doICF(ArrayRef Chunks); class COFFOptTable : public llvm::opt::OptTable { public: @@ -171,7 +171,7 @@ void checkFailIfMismatch(StringRef Arg); // Convert Windows resource files (.res files) to a .obj file. -MemoryBufferRef convertResToCOFF(const std::vector &MBs); +MemoryBufferRef convertResToCOFF(ArrayRef MBs); void runMSVCLinker(std::string Rsp, ArrayRef Objects); Index: COFF/DriverUtils.cpp =================================================================== --- COFF/DriverUtils.cpp +++ COFF/DriverUtils.cpp @@ -642,7 +642,7 @@ } // Convert Windows resource files (.res files) to a .obj file. -MemoryBufferRef convertResToCOFF(const std::vector &MBs) { +MemoryBufferRef convertResToCOFF(ArrayRef MBs) { object::WindowsResourceParser Parser; for (MemoryBufferRef MB : MBs) { Index: COFF/ICF.cpp =================================================================== --- COFF/ICF.cpp +++ COFF/ICF.cpp @@ -36,7 +36,7 @@ class ICF { public: - void run(const std::vector &V); + void run(ArrayRef V); private: void segregate(size_t Begin, size_t End, bool Constant); @@ -206,7 +206,7 @@ // Merge identical COMDAT sections. // Two sections are considered the same if their section headers, // contents and relocations are all the same. -void ICF::run(const std::vector &Vec) { +void ICF::run(ArrayRef Vec) { // Collect only mergeable sections and group by hash value. uint32_t NextId = 1; for (Chunk *C : Vec) { @@ -257,7 +257,7 @@ } // Entry point to ICF. -void doICF(const std::vector &Chunks) { ICF().run(Chunks); } +void doICF(ArrayRef Chunks) { ICF().run(Chunks); } } // namespace coff } // namespace lld Index: COFF/InputFiles.h =================================================================== --- COFF/InputFiles.h +++ COFF/InputFiles.h @@ -108,9 +108,9 @@ static bool classof(const InputFile *F) { return F->kind() == ObjectKind; } void parse() override; MachineTypes getMachineType() override; - std::vector &getChunks() { return Chunks; } - std::vector &getDebugChunks() { return DebugChunks; } - std::vector &getSymbols() { return Symbols; } + ArrayRef getChunks() { return Chunks; } + ArrayRef getDebugChunks() { return DebugChunks; } + ArrayRef getSymbols() { return Symbols; } // Returns a Symbol object for the SymbolIndex'th symbol in the // underlying object file. @@ -217,7 +217,7 @@ public: explicit BitcodeFile(MemoryBufferRef M) : InputFile(BitcodeKind, M) {} static bool classof(const InputFile *F) { return F->kind() == BitcodeKind; } - std::vector &getSymbols() { return SymbolBodies; } + ArrayRef getSymbols() { return SymbolBodies; } MachineTypes getMachineType() override; static std::vector Instances; std::unique_ptr Obj; Index: COFF/MarkLive.cpp =================================================================== --- COFF/MarkLive.cpp +++ COFF/MarkLive.cpp @@ -18,7 +18,7 @@ // Set live bit on for each reachable chunk. Unmarked (unreachable) // COMDAT chunks will be ignored by Writer, so they will be excluded // from the final output. -void markLive(const std::vector &Chunks) { +void markLive(ArrayRef Chunks) { // We build up a worklist of sections which have been marked as live. We only // push into the worklist when we discover an unmarked section, and we mark // as we push, so sections never appear twice in the list. Index: COFF/PDB.cpp =================================================================== --- COFF/PDB.cpp +++ COFF/PDB.cpp @@ -136,7 +136,7 @@ }; } -static SectionChunk *findByName(std::vector &Sections, +static SectionChunk *findByName(ArrayRef Sections, StringRef Name) { for (SectionChunk *C : Sections) if (C->getSectionName() == Name) Index: COFF/SymbolTable.cpp =================================================================== --- COFF/SymbolTable.cpp +++ COFF/SymbolTable.cpp @@ -291,7 +291,7 @@ std::vector SymbolTable::getChunks() { std::vector Res; for (ObjFile *File : ObjFile::Instances) { - std::vector &V = File->getChunks(); + ArrayRef V = File->getChunks(); Res.insert(Res.end(), V.begin(), V.end()); } return Res; Index: COFF/Writer.h =================================================================== --- COFF/Writer.h +++ COFF/Writer.h @@ -34,7 +34,7 @@ void setFileOffset(uint64_t); void addChunk(Chunk *C); llvm::StringRef getName() { return Name; } - std::vector &getChunks() { return Chunks; } + ArrayRef getChunks() { return Chunks; } void addPermissions(uint32_t C); void setPermissions(uint32_t C); uint32_t getPermissions() { return Header.Characteristics & PermMask; } Index: include/lld/Core/LinkingContext.h =================================================================== --- include/lld/Core/LinkingContext.h +++ include/lld/Core/LinkingContext.h @@ -62,7 +62,7 @@ /// of DefinedAtoms that should be marked live (along with all Atoms they /// reference). Only Atoms with scope scopeLinkageUnit or scopeGlobal can /// be kept live using this method. - const std::vector &deadStripRoots() const { + ArrayRef deadStripRoots() const { return _deadStripRoots; } @@ -106,7 +106,7 @@ /// options which are used to configure LLVM's command line settings. /// For instance the -debug-only XXX option can be used to dynamically /// trace different parts of LLVM and lld. - const std::vector &llvmOptions() const { return _llvmOptions; } + ArrayRef llvmOptions() const { return _llvmOptions; } /// \name Methods used by Drivers to configure TargetInfo /// @{ Index: wasm/InputFiles.h =================================================================== --- wasm/InputFiles.h +++ wasm/InputFiles.h @@ -112,7 +112,7 @@ std::vector TypeMap; std::vector Segments; - const std::vector &getSymbols() { return Symbols; } + ArrayRef getSymbols() { return Symbols; } private: Symbol *createDefined(const WasmSymbol &Sym, Index: wasm/OutputSections.h =================================================================== --- wasm/OutputSections.h +++ wasm/OutputSections.h @@ -105,21 +105,21 @@ class CodeSection : public OutputSection { public: - explicit CodeSection(uint32_t NumFunctions, std::vector &Objs); + explicit CodeSection(uint32_t NumFunctions, ArrayRef Objs); size_t getSize() const override { return Header.size() + BodySize; } void writeTo(uint8_t *Buf) override; uint32_t numRelocations() const override; void writeRelocations(raw_ostream &OS) const override; protected: - std::vector &InputObjects; + ArrayRef InputObjects; std::string CodeSectionHeader; size_t BodySize = 0; }; class DataSection : public OutputSection { public: - explicit DataSection(std::vector &Segments); + explicit DataSection(ArrayRef Segments); size_t getSize() const override { return Header.size() + BodySize; } void writeTo(uint8_t *Buf) override; uint32_t numRelocations() const override { return Relocations.size(); } @@ -127,7 +127,7 @@ protected: std::vector Relocations; - std::vector &Segments; + ArrayRef Segments; std::string DataSectionHeader; size_t BodySize = 0; }; Index: wasm/OutputSections.cpp =================================================================== --- wasm/OutputSections.cpp +++ wasm/OutputSections.cpp @@ -109,7 +109,7 @@ } static void applyRelocations(uint8_t *Buf, - const std::vector &Relocs) { + ArrayRef Relocs) { log("applyRelocations: count=" + Twine(Relocs.size())); for (const OutputRelocation &Reloc : Relocs) { applyRelocation(Buf, Reloc); @@ -188,7 +188,7 @@ " total=" + Twine(getSize())); } -CodeSection::CodeSection(uint32_t NumFunctions, std::vector &Objs) +CodeSection::CodeSection(uint32_t NumFunctions, ArrayRef Objs) : OutputSection(WASM_SEC_CODE), InputObjects(Objs) { raw_string_ostream OS(CodeSectionHeader); writeUleb128(OS, NumFunctions, "function count"); @@ -263,7 +263,7 @@ writeReloc(OS, Reloc); } -DataSection::DataSection(std::vector &Segments) +DataSection::DataSection(ArrayRef Segments) : OutputSection(WASM_SEC_DATA), Segments(Segments) { raw_string_ostream OS(DataSectionHeader);