diff options
-rw-r--r-- | lld/include/lld/Core/LinkingContext.h | 6 | ||||
-rw-r--r-- | lld/include/lld/Core/Resolver.h | 4 | ||||
-rw-r--r-- | lld/include/lld/Driver/Driver.h | 2 | ||||
-rw-r--r-- | lld/include/lld/ReaderWriter/CoreLinkingContext.h | 4 | ||||
-rw-r--r-- | lld/include/lld/ReaderWriter/ELFLinkingContext.h | 1 | ||||
-rw-r--r-- | lld/include/lld/ReaderWriter/PECOFFLinkingContext.h | 7 | ||||
-rw-r--r-- | lld/lib/Core/LinkingContext.cpp | 4 | ||||
-rw-r--r-- | lld/lib/Driver/Driver.cpp | 2 | ||||
-rw-r--r-- | lld/lib/ReaderWriter/CoreLinkingContext.cpp | 9 | ||||
-rw-r--r-- | lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp | 2 |
10 files changed, 18 insertions, 23 deletions
diff --git a/lld/include/lld/Core/LinkingContext.h b/lld/include/lld/Core/LinkingContext.h index 47805f44c27..525e1fe5d97 100644 --- a/lld/include/lld/Core/LinkingContext.h +++ b/lld/include/lld/Core/LinkingContext.h @@ -305,14 +305,14 @@ public: /// the resolver operates. This uses the currentInputElement. When there are /// no more files to be processed an appropriate input_graph_error is /// returned. - virtual ErrorOr<File &> nextFile() const; + virtual ErrorOr<File &> nextFile(); /// Set the resolver state for the current Input element This is used by the /// InputGraph to decide the next file that needs to be processed for various /// types of nodes in the InputGraph. The resolver state is nothing but a /// bitmask of various types of states that the resolver handles when adding /// atoms. - virtual void setResolverState(uint32_t resolverState) const; + virtual void setResolverState(uint32_t resolverState); /// @} @@ -362,7 +362,7 @@ protected: StringRefVector _initialUndefinedSymbols; std::unique_ptr<InputGraph> _inputGraph; mutable llvm::BumpPtrAllocator _allocator; - mutable InputElement *_currentInputElement; + InputElement *_currentInputElement; private: /// Validate the subclass bits. Only called by validate. diff --git a/lld/include/lld/Core/Resolver.h b/lld/include/lld/Core/Resolver.h index b94486fc340..b0dc268efc3 100644 --- a/lld/include/lld/Core/Resolver.h +++ b/lld/include/lld/Core/Resolver.h @@ -36,7 +36,7 @@ public: StateNewAbsoluteAtoms = 8 // New absolute atoms were added }; - Resolver(const LinkingContext &context) + Resolver(LinkingContext &context) : _context(context), _symbolTable(context), _result(context), _haveLLVMObjs(false), _addToFinalSection(false) {} @@ -111,7 +111,7 @@ private: atom_collection_vector<AbsoluteAtom> _absoluteAtoms; }; - const LinkingContext &_context; + LinkingContext &_context; SymbolTable _symbolTable; std::vector<const Atom *> _atoms; std::set<const Atom *> _deadStripRoots; diff --git a/lld/include/lld/Driver/Driver.h b/lld/include/lld/Driver/Driver.h index 72d4fcca339..a2773d68d94 100644 --- a/lld/include/lld/Driver/Driver.h +++ b/lld/include/lld/Driver/Driver.h @@ -38,7 +38,7 @@ class Driver { protected: /// Performs link using specified options - static bool link(const LinkingContext &context, + static bool link(LinkingContext &context, raw_ostream &diagnostics = llvm::errs()); private: diff --git a/lld/include/lld/ReaderWriter/CoreLinkingContext.h b/lld/include/lld/ReaderWriter/CoreLinkingContext.h index d7200a627de..9f6fcdd0574 100644 --- a/lld/include/lld/ReaderWriter/CoreLinkingContext.h +++ b/lld/include/lld/ReaderWriter/CoreLinkingContext.h @@ -35,8 +35,8 @@ protected: virtual Writer &writer() const; private: - mutable std::unique_ptr<Reader> _reader; - mutable std::unique_ptr<Writer> _writer; + std::unique_ptr<Reader> _reader; + std::unique_ptr<Writer> _writer; std::vector<StringRef> _passNames; }; diff --git a/lld/include/lld/ReaderWriter/ELFLinkingContext.h b/lld/include/lld/ReaderWriter/ELFLinkingContext.h index ec933706a05..9a244300ccd 100644 --- a/lld/include/lld/ReaderWriter/ELFLinkingContext.h +++ b/lld/include/lld/ReaderWriter/ELFLinkingContext.h @@ -230,7 +230,6 @@ protected: bool _noAllowDynamicLibraries; OutputMagic _outputMagic; StringRefVector _inputSearchPaths; - mutable llvm::BumpPtrAllocator _alloc; std::unique_ptr<Reader> _elfReader; std::unique_ptr<Writer> _writer; std::unique_ptr<Reader> _linkerScriptReader; diff --git a/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h b/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h index f626c7cec09..4f09d14ee83 100644 --- a/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h +++ b/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h @@ -162,7 +162,7 @@ public: virtual ErrorOr<std::string> stringFromRelocKind(Reference::Kind kind) const; StringRef allocateString(StringRef ref) const { - char *x = _alloc.Allocate<char>(ref.size() + 1); + char *x = _allocator.Allocate<char>(ref.size() + 1); memcpy(x, ref.data(), ref.size()); x[ref.size()] = '\0'; return x; @@ -211,9 +211,8 @@ private: std::set<std::string> _noDefaultLibs; std::vector<StringRef> _inputSearchPaths; - mutable std::unique_ptr<Reader> _reader; - mutable std::unique_ptr<Writer> _writer; - mutable llvm::BumpPtrAllocator _alloc; + std::unique_ptr<Reader> _reader; + std::unique_ptr<Writer> _writer; }; } // end namespace lld diff --git a/lld/lib/Core/LinkingContext.cpp b/lld/lib/Core/LinkingContext.cpp index 5d5d34fb149..22a9ccf6e05 100644 --- a/lld/lib/Core/LinkingContext.cpp +++ b/lld/lib/Core/LinkingContext.cpp @@ -76,11 +76,11 @@ bool LinkingContext::createInternalFiles( return true; } -void LinkingContext::setResolverState(uint32_t state) const { +void LinkingContext::setResolverState(uint32_t state) { _currentInputElement->setResolverState(state); } -ErrorOr<File &> LinkingContext::nextFile() const { +ErrorOr<File &> LinkingContext::nextFile() { // When nextFile() is called for the first time, _currentInputElement is not // initialized. Initialize it with the first element of the input graph. if (_currentInputElement == nullptr) { diff --git a/lld/lib/Driver/Driver.cpp b/lld/lib/Driver/Driver.cpp index 077afdaa654..e0b81eae859 100644 --- a/lld/lib/Driver/Driver.cpp +++ b/lld/lib/Driver/Driver.cpp @@ -28,7 +28,7 @@ namespace lld { /// This is where the link is actually performed. -bool Driver::link(const LinkingContext &context, raw_ostream &diagnostics) { +bool Driver::link(LinkingContext &context, raw_ostream &diagnostics) { // Honor -mllvm if (!context.llvmOptions().empty()) { unsigned numArgs = context.llvmOptions().size(); diff --git a/lld/lib/ReaderWriter/CoreLinkingContext.cpp b/lld/lib/ReaderWriter/CoreLinkingContext.cpp index bc9a009673d..db17d57d43e 100644 --- a/lld/lib/ReaderWriter/CoreLinkingContext.cpp +++ b/lld/lib/ReaderWriter/CoreLinkingContext.cpp @@ -271,8 +271,9 @@ private: CoreLinkingContext::CoreLinkingContext() {} -bool CoreLinkingContext::validateImpl(raw_ostream &diagnostics) { +bool CoreLinkingContext::validateImpl(raw_ostream &) { _reader = createReaderYAML(*this); + _writer = createWriterYAML(*this); return true; } @@ -289,11 +290,7 @@ void CoreLinkingContext::addPasses(PassManager &pm) const { } } -Writer &CoreLinkingContext::writer() const { - if (!_writer) - _writer = createWriterYAML(*this); - return *_writer; -} +Writer &CoreLinkingContext::writer() const { return *_writer; } ErrorOr<Reference::Kind> CoreLinkingContext::relocKindFromString(StringRef str) const { diff --git a/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp b/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp index 6d7f786e002..bf1a4a7c3b8 100644 --- a/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp +++ b/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp @@ -167,7 +167,7 @@ llvm::ErrorOr<StringRef> ELFLinkingContext::searchLibrary( } } if (foundFile) - return StringRef(*new (_alloc) std::string(pathref)); + return StringRef(*new (_allocator) std::string(pathref)); } if (!llvm::sys::fs::exists(libName)) return llvm::make_error_code(llvm::errc::no_such_file_or_directory); |