diff --git a/lld/include/lld/Core/InputGraph.h b/lld/include/lld/Core/InputGraph.h index 1b357a2940a7..6c63d5cb706c 100644 --- a/lld/include/lld/Core/InputGraph.h +++ b/lld/include/lld/Core/InputGraph.h @@ -49,10 +49,6 @@ public: typedef std::vector > FileVectorT; typedef FileVectorT::iterator FileIterT; - /// Where do we want to insert the input element when calling the - /// insertElementAt. - enum Position : uint8_t { BEGIN, END }; - /// \brief Initialize the inputgraph InputGraph() : _nextElementIndex(0), _currentInputElement(nullptr) {} @@ -77,6 +73,9 @@ public: /// \brief Adds a node into the InputGraph void addInputElement(std::unique_ptr); + /// \brief Adds a node at the beginning of the InputGraph + void addInputElementFront(std::unique_ptr); + /// Normalize the InputGraph. It calls expand() on each node and then replace /// it with getReplacements() results. void normalize(); @@ -91,9 +90,6 @@ public: /// \brief Dump the input Graph bool dump(raw_ostream &diagnostics = llvm::errs()); - /// \brief Insert an element into the input graph at position. - void insertElementAt(std::unique_ptr, Position position); - protected: // Input arguments InputElementVectorT _inputArgs; diff --git a/lld/lib/Core/InputGraph.cpp b/lld/lib/Core/InputGraph.cpp index 9a76e93fc092..bdef8c3ffe1c 100644 --- a/lld/lib/Core/InputGraph.cpp +++ b/lld/lib/Core/InputGraph.cpp @@ -46,6 +46,10 @@ void InputGraph::addInputElement(std::unique_ptr ie) { _inputArgs.push_back(std::move(ie)); } +void InputGraph::addInputElementFront(std::unique_ptr ie) { + _inputArgs.insert(_inputArgs.begin(), std::move(ie)); +} + bool InputGraph::dump(raw_ostream &diagnostics) { for (std::unique_ptr &ie : _inputArgs) if (!ie->dump(diagnostics)) @@ -53,17 +57,6 @@ bool InputGraph::dump(raw_ostream &diagnostics) { return true; } -/// \brief Insert element at position -void InputGraph::insertElementAt(std::unique_ptr element, - Position position) { - if (position == InputGraph::Position::BEGIN) { - _inputArgs.insert(_inputArgs.begin(), std::move(element)); - return; - } - assert(position == InputGraph::Position::END); - _inputArgs.push_back(std::move(element)); -} - /// \brief Helper functions for the resolver ErrorOr InputGraph::getNextInputElement() { if (_nextElementIndex >= _inputArgs.size()) diff --git a/lld/lib/Driver/Driver.cpp b/lld/lib/Driver/Driver.cpp index e8567ed6897e..9e57ed7e36d6 100644 --- a/lld/lib/Driver/Driver.cpp +++ b/lld/lib/Driver/Driver.cpp @@ -101,8 +101,7 @@ bool Driver::link(LinkingContext &context, raw_ostream &diagnostics) { context.createImplicitFiles(implicitFiles); if (implicitFiles.size()) fileNode->addFiles(std::move(implicitFiles)); - context.getInputGraph().insertElementAt(std::move(fileNode), - InputGraph::Position::BEGIN); + context.getInputGraph().addInputElementFront(std::move(fileNode)); // Do core linking. ScopedTask resolveTask(getDefaultDomain(), "Resolve");