[lld] r234354 - Merge MutableFile with SimpleFile.

Rui Ueyama ruiu at google.com
Tue Apr 7 13:43:39 PDT 2015


Author: ruiu
Date: Tue Apr  7 15:43:38 2015
New Revision: 234354

URL: http://llvm.org/viewvc/llvm-project?rev=234354&view=rev
Log:
Merge MutableFile with SimpleFile.

SimpleFile is the only derived class of MutableFile.
This patch reduces the height of class hierarchy by removing
MutableFile class.

Modified:
    lld/trunk/include/lld/Core/File.h
    lld/trunk/include/lld/Core/Pass.h
    lld/trunk/include/lld/Core/PassManager.h
    lld/trunk/include/lld/Core/Resolver.h
    lld/trunk/include/lld/Core/Simple.h
    lld/trunk/lib/Driver/Driver.cpp
    lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp
    lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp
    lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp
    lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp
    lld/trunk/lib/ReaderWriter/ELF/Mips/MipsCtorsOrderPass.cpp
    lld/trunk/lib/ReaderWriter/ELF/Mips/MipsCtorsOrderPass.h
    lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp
    lld/trunk/lib/ReaderWriter/ELF/OrderPass.h
    lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp
    lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
    lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp
    lld/trunk/lib/ReaderWriter/MachO/LayoutPass.cpp
    lld/trunk/lib/ReaderWriter/MachO/LayoutPass.h
    lld/trunk/lib/ReaderWriter/MachO/ShimPass.cpp
    lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp
    lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.cpp
    lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.h
    lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp
    lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.h
    lld/trunk/lib/ReaderWriter/PECOFF/InferSubsystemPass.h
    lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.cpp
    lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.h
    lld/trunk/lib/ReaderWriter/PECOFF/OrderPass.h
    lld/trunk/lib/ReaderWriter/PECOFF/PDBPass.h

Modified: lld/trunk/include/lld/Core/File.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/File.h?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/File.h (original)
+++ lld/trunk/include/lld/Core/File.h Tue Apr  7 15:43:38 2015
@@ -272,24 +272,6 @@ private:
   std::mutex _parseMutex;
 };
 
-/// \brief A mutable File.
-class MutableFile : public File {
-public:
-  /// \brief Add an atom to the file. Invalidates iterators for all returned
-  /// containters.
-  virtual void addAtom(const Atom&) = 0;
-
-  typedef range<std::vector<const DefinedAtom *>::iterator> DefinedAtomRange;
-  virtual DefinedAtomRange definedAtoms() = 0;
-
-  virtual void
-  removeDefinedAtomsIf(std::function<bool(const DefinedAtom *)> pred) = 0;
-
-protected:
-  /// \brief only subclasses of MutableFile can be instantiated
-  MutableFile(StringRef p) : File(p, kindObject) {}
-};
-
 /// An ErrorFile represents a file that doesn't exist.
 /// If you try to parse a file which doesn't exist, an instance of this
 /// class will be returned. That's parse method always returns an error.

Modified: lld/trunk/include/lld/Core/Pass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Pass.h?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Pass.h (original)
+++ lld/trunk/include/lld/Core/Pass.h Tue Apr  7 15:43:38 2015
@@ -17,7 +17,7 @@
 #include <vector>
 
 namespace lld {
-class MutableFile;
+class SimpleFile;
 
 /// Once the core linking is done (which resolves references, coalesces atoms
 /// and produces a complete Atom graph), the linker runs a series of passes
@@ -34,7 +34,7 @@ public:
   virtual ~Pass() { }
 
   /// Do the actual work of the Pass.
-  virtual void perform(std::unique_ptr<MutableFile> &mergedFile) = 0;
+  virtual void perform(std::unique_ptr<SimpleFile> &mergedFile) = 0;
 
 protected:
   // Only subclassess can be instantiated.

Modified: lld/trunk/include/lld/Core/PassManager.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/PassManager.h?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/PassManager.h (original)
+++ lld/trunk/include/lld/Core/PassManager.h Tue Apr  7 15:43:38 2015
@@ -16,7 +16,7 @@
 #include <vector>
 
 namespace lld {
-class MutableFile;
+class SimpleFile;
 class Pass;
 
 /// \brief Owns and runs a collection of passes.
@@ -31,7 +31,7 @@ public:
     _passes.push_back(std::move(pass));
   }
 
-  std::error_code runOnFile(std::unique_ptr<MutableFile> &file) {
+  std::error_code runOnFile(std::unique_ptr<SimpleFile> &file) {
     for (std::unique_ptr<Pass> &pass : _passes)
       pass->perform(file);
     return std::error_code();

Modified: lld/trunk/include/lld/Core/Resolver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Resolver.h?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Resolver.h (original)
+++ lld/trunk/include/lld/Core/Resolver.h Tue Apr  7 15:43:38 2015
@@ -54,7 +54,7 @@ public:
   /// @brief do work of merging and resolving and return list
   bool resolve();
 
-  std::unique_ptr<MutableFile> resultFile() { return std::move(_result); }
+  std::unique_ptr<SimpleFile> resultFile() { return std::move(_result); }
 
 private:
   typedef std::function<void(StringRef, bool)> UndefCallback;

Modified: lld/trunk/include/lld/Core/Simple.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Simple.h?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Simple.h (original)
+++ lld/trunk/include/lld/Core/Simple.h Tue Apr  7 15:43:38 2015
@@ -26,11 +26,11 @@
 
 namespace lld {
 
-class SimpleFile : public MutableFile {
+class SimpleFile : public File {
 public:
-  SimpleFile(StringRef path) : MutableFile(path) {}
+  SimpleFile(StringRef path) : File(path, kindObject) {}
 
-  void addAtom(const Atom &atom) override {
+  void addAtom(const Atom &atom) {
     if (auto *defAtom = dyn_cast<DefinedAtom>(&atom)) {
       _definedAtoms._atoms.push_back(defAtom);
     } else if (auto *undefAtom = dyn_cast<UndefinedAtom>(&atom)) {
@@ -44,8 +44,7 @@ public:
     }
   }
 
-  void
-  removeDefinedAtomsIf(std::function<bool(const DefinedAtom *)> pred) override {
+  void removeDefinedAtomsIf(std::function<bool(const DefinedAtom *)> pred) {
     auto &atoms = _definedAtoms._atoms;
     auto newEnd = std::remove_if(atoms.begin(), atoms.end(), pred);
     atoms.erase(newEnd, atoms.end());
@@ -67,9 +66,8 @@ public:
     return _absoluteAtoms;
   }
 
-  DefinedAtomRange definedAtoms() override {
-    return make_range(_definedAtoms._atoms);
-  }
+  typedef range<std::vector<const DefinedAtom *>::iterator> DefinedAtomRange;
+  DefinedAtomRange definedAtoms() { return make_range(_definedAtoms._atoms); }
 
 private:
   atom_collection_vector<DefinedAtom>        _definedAtoms;

Modified: lld/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/Driver.cpp?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/Driver/Driver.cpp (original)
+++ lld/trunk/lib/Driver/Driver.cpp Tue Apr  7 15:43:38 2015
@@ -108,7 +108,7 @@ bool Driver::link(LinkingContext &ctx, r
     ctx.getTaskGroup().sync();
     return false;
   }
-  std::unique_ptr<MutableFile> merged = resolver.resultFile();
+  std::unique_ptr<SimpleFile> merged = resolver.resultFile();
   resolveTask.end();
 
   // Run passes on linked atoms.

Modified: lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp Tue Apr  7 15:43:38 2015
@@ -144,8 +144,8 @@ private:
 class OrderPass : public Pass {
 public:
   /// Sorts atoms by position
-  void perform(std::unique_ptr<MutableFile> &file) override {
-    MutableFile::DefinedAtomRange defined = file->definedAtoms();
+  void perform(std::unique_ptr<SimpleFile> &file) override {
+    SimpleFile::DefinedAtomRange defined = file->definedAtoms();
     std::sort(defined.begin(), defined.end(), DefinedAtom::compareByPosition);
   }
 };

Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp Tue Apr  7 15:43:38 2015
@@ -254,7 +254,7 @@ public:
   ///
   /// After all references are handled, the atoms created during that are all
   /// added to mf.
-  void perform(std::unique_ptr<MutableFile> &mf) override {
+  void perform(std::unique_ptr<SimpleFile> &mf) override {
     ScopedTask task(getDefaultDomain(), "AArch64 GOT/PLT Pass");
     DEBUG_WITH_TYPE(
         "AArch64", llvm::dbgs() << "Undefined Atoms"

Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp Tue Apr  7 15:43:38 2015
@@ -482,7 +482,7 @@ public:
   ///
   /// After all references are handled, the atoms created during that are all
   /// added to mf.
-  void perform(std::unique_ptr<MutableFile> &mf) override {
+  void perform(std::unique_ptr<SimpleFile> &mf) override {
     ScopedTask task(getDefaultDomain(), "ARM GOT/PLT Pass");
     DEBUG_WITH_TYPE(
         "ARM", llvm::dbgs() << "Undefined Atoms" << "\n";

Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp Tue Apr  7 15:43:38 2015
@@ -171,7 +171,7 @@ public:
   ///
   /// After all references are handled, the atoms created during that are all
   /// added to mf.
-  void perform(std::unique_ptr<MutableFile> &mf) override {
+  void perform(std::unique_ptr<SimpleFile> &mf) override {
     // Process all references.
     for (const auto &atom : mf->defined())
       for (const auto &ref : *atom)

Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsCtorsOrderPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsCtorsOrderPass.cpp?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsCtorsOrderPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsCtorsOrderPass.cpp Tue Apr  7 15:43:38 2015
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "MipsCtorsOrderPass.h"
+#include "lld/Core/Simple.h"
 #include <algorithm>
 #include <climits>
 
@@ -48,7 +49,7 @@ static int32_t getSectionPriority(String
   return priority;
 }
 
-void MipsCtorsOrderPass::perform(std::unique_ptr<MutableFile> &f) {
+void MipsCtorsOrderPass::perform(std::unique_ptr<SimpleFile> &f) {
   auto definedAtoms = f->definedAtoms();
 
   auto last = std::stable_partition(definedAtoms.begin(), definedAtoms.end(),

Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsCtorsOrderPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsCtorsOrderPass.h?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsCtorsOrderPass.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsCtorsOrderPass.h Tue Apr  7 15:43:38 2015
@@ -17,7 +17,7 @@ namespace elf {
 /// \brief This pass sorts atoms in .{ctors,dtors}.<priority> sections.
 class MipsCtorsOrderPass : public Pass {
 public:
-  void perform(std::unique_ptr<MutableFile> &mergedFile) override;
+  void perform(std::unique_ptr<SimpleFile> &mergedFile) override;
 };
 }
 }

Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp Tue Apr  7 15:43:38 2015
@@ -295,7 +295,7 @@ template <typename ELFT> class Relocatio
 public:
   RelocationPass(MipsLinkingContext &ctx);
 
-  void perform(std::unique_ptr<MutableFile> &mf) override;
+  void perform(std::unique_ptr<SimpleFile> &mf) override;
 
 private:
   /// \brief Reference to the linking context.
@@ -418,7 +418,7 @@ RelocationPass<ELFT>::RelocationPass(Mip
 }
 
 template <typename ELFT>
-void RelocationPass<ELFT>::perform(std::unique_ptr<MutableFile> &mf) {
+void RelocationPass<ELFT>::perform(std::unique_ptr<SimpleFile> &mf) {
   for (const auto &atom : mf->defined())
     for (const auto &ref : *atom)
       collectReferenceInfo(*cast<MipsELFDefinedAtom<ELFT>>(atom),

Modified: lld/trunk/lib/ReaderWriter/ELF/OrderPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/OrderPass.h?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/OrderPass.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/OrderPass.h Tue Apr  7 15:43:38 2015
@@ -19,7 +19,7 @@ namespace elf {
 /// \brief This pass sorts atoms by file and atom ordinals.
 class OrderPass : public Pass {
 public:
-  void perform(std::unique_ptr<MutableFile> &file) override {
+  void perform(std::unique_ptr<SimpleFile> &file) override {
     parallel_sort(file->definedAtoms().begin(), file->definedAtoms().end(),
                   DefinedAtom::compareByPosition);
   }

Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp Tue Apr  7 15:43:38 2015
@@ -253,7 +253,7 @@ public:
   ///
   /// After all references are handled, the atoms created during that are all
   /// added to mf.
-  void perform(std::unique_ptr<MutableFile> &mf) override {
+  void perform(std::unique_ptr<SimpleFile> &mf) override {
     ScopedTask task(getDefaultDomain(), "X86-64 GOT/PLT Pass");
     // Process all references.
     for (const auto &atom : mf->defined())

Modified: lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp Tue Apr  7 15:43:38 2015
@@ -277,7 +277,7 @@ public:
         _isBig(MachOLinkingContext::isBigEndian(_context.arch())) {}
 
 private:
-  void perform(std::unique_ptr<MutableFile> &mergedFile) override {
+  void perform(std::unique_ptr<SimpleFile> &mergedFile) override {
     DEBUG(llvm::dbgs() << "MachO Compact Unwind pass\n");
 
     std::map<const Atom *, CompactUnwindEntry> unwindLocs;
@@ -351,7 +351,7 @@ private:
   }
 
   void collectCompactUnwindEntries(
-      std::unique_ptr<MutableFile> &mergedFile,
+      std::unique_ptr<SimpleFile> &mergedFile,
       std::map<const Atom *, CompactUnwindEntry> &unwindLocs,
       std::vector<const Atom *> &personalities, uint32_t &numLSDAs) {
     DEBUG(llvm::dbgs() << "  Collecting __compact_unwind entries\n");
@@ -422,7 +422,7 @@ private:
   }
 
   void
-  collectDwarfFrameEntries(std::unique_ptr<MutableFile> &mergedFile,
+  collectDwarfFrameEntries(std::unique_ptr<SimpleFile> &mergedFile,
                            std::map<const Atom *, const Atom *> &dwarfFrames) {
     for (const DefinedAtom *ehFrameAtom : mergedFile->defined()) {
       if (ehFrameAtom->contentType() != DefinedAtom::typeCFI)
@@ -442,7 +442,7 @@ private:
   ///   + A synthesised reference to __eh_frame if there's no __compact_unwind
   ///     or too many personality functions to be accommodated.
   std::vector<CompactUnwindEntry> createUnwindInfoEntries(
-      const std::unique_ptr<MutableFile> &mergedFile,
+      const std::unique_ptr<SimpleFile> &mergedFile,
       const std::map<const Atom *, CompactUnwindEntry> &unwindLocs,
       const std::vector<const Atom *> &personalities,
       const std::map<const Atom *, const Atom *> &dwarfFrames) {

Modified: lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp Tue Apr  7 15:43:38 2015
@@ -96,8 +96,7 @@ public:
       _file("<mach-o GOT Pass>") { }
 
 private:
-
-  void perform(std::unique_ptr<MutableFile> &mergedFile) override {
+  void perform(std::unique_ptr<SimpleFile> &mergedFile) override {
     // Scan all references in all atoms.
     for (const DefinedAtom *atom : mergedFile->defined()) {
       for (const Reference *ref : *atom) {

Modified: lld/trunk/lib/ReaderWriter/MachO/LayoutPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/LayoutPass.cpp?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/LayoutPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/LayoutPass.cpp Tue Apr  7 15:43:38 2015
@@ -133,7 +133,7 @@ static void checkReachabilityFromRoot(At
   }
 }
 
-static void printDefinedAtoms(const MutableFile::DefinedAtomRange &atomRange) {
+static void printDefinedAtoms(const SimpleFile::DefinedAtomRange &atomRange) {
   for (const DefinedAtom *atom : atomRange) {
     llvm::dbgs() << "  file=" << atom->file().path()
                  << ", name=" << atom->name()
@@ -146,7 +146,7 @@ static void printDefinedAtoms(const Muta
 
 /// Verify that the followon chain is sane. Should not be called in
 /// release binary.
-void LayoutPass::checkFollowonChain(MutableFile::DefinedAtomRange &range) {
+void LayoutPass::checkFollowonChain(SimpleFile::DefinedAtomRange &range) {
   ScopedTask task(getDefaultDomain(), "LayoutPass::checkFollowonChain");
 
   // Verify that there's no cycle in follow-on chain.
@@ -329,7 +329,7 @@ void LayoutPass::setChainRoot(const Defi
 /// d) If the targetAtom is part of a different chain and the root of the
 ///    targetAtom until the targetAtom has all atoms of size 0, then chain the
 ///    targetAtoms and its tree to the current chain
-void LayoutPass::buildFollowOnTable(MutableFile::DefinedAtomRange &range) {
+void LayoutPass::buildFollowOnTable(SimpleFile::DefinedAtomRange &range) {
   ScopedTask task(getDefaultDomain(), "LayoutPass::buildFollowOnTable");
   // Set the initial size of the followon and the followonNext hash to the
   // number of atoms that we have.
@@ -397,7 +397,7 @@ void LayoutPass::buildFollowOnTable(Muta
 /// assigning ordinals to each atom, if the atoms have their ordinals
 /// already assigned skip the atom and move to the next. This is the
 /// main map thats used to sort the atoms while comparing two atoms together
-void LayoutPass::buildOrdinalOverrideMap(MutableFile::DefinedAtomRange &range) {
+void LayoutPass::buildOrdinalOverrideMap(SimpleFile::DefinedAtomRange &range) {
   ScopedTask task(getDefaultDomain(), "LayoutPass::buildOrdinalOverrideMap");
   uint64_t index = 0;
   for (const DefinedAtom *ai : range) {
@@ -417,7 +417,7 @@ void LayoutPass::buildOrdinalOverrideMap
 }
 
 std::vector<LayoutPass::SortKey>
-LayoutPass::decorate(MutableFile::DefinedAtomRange &atomRange) const {
+LayoutPass::decorate(SimpleFile::DefinedAtomRange &atomRange) const {
   std::vector<SortKey> ret;
   for (const DefinedAtom *atom : atomRange) {
     auto ri = _followOnRoots.find(atom);
@@ -429,7 +429,7 @@ LayoutPass::decorate(MutableFile::Define
   return ret;
 }
 
-void LayoutPass::undecorate(MutableFile::DefinedAtomRange &atomRange,
+void LayoutPass::undecorate(SimpleFile::DefinedAtomRange &atomRange,
                             std::vector<SortKey> &keys) const {
   size_t i = 0;
   for (SortKey &k : keys)
@@ -437,10 +437,10 @@ void LayoutPass::undecorate(MutableFile:
 }
 
 /// Perform the actual pass
-void LayoutPass::perform(std::unique_ptr<MutableFile> &mergedFile) {
+void LayoutPass::perform(std::unique_ptr<SimpleFile> &mergedFile) {
   // sort the atoms
   ScopedTask task(getDefaultDomain(), "LayoutPass");
-  MutableFile::DefinedAtomRange atomRange = mergedFile->definedAtoms();
+  SimpleFile::DefinedAtomRange atomRange = mergedFile->definedAtoms();
 
   // Build follow on tables
   buildFollowOnTable(atomRange);

Modified: lld/trunk/lib/ReaderWriter/MachO/LayoutPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/LayoutPass.h?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/LayoutPass.h (original)
+++ lld/trunk/lib/ReaderWriter/MachO/LayoutPass.h Tue Apr  7 15:43:38 2015
@@ -13,6 +13,7 @@
 #include "lld/Core/File.h"
 #include "lld/Core/Pass.h"
 #include "lld/Core/Reader.h"
+#include "lld/Core/Simple.h"
 #include "llvm/ADT/DenseMap.h"
 #include <map>
 #include <string>
@@ -20,7 +21,7 @@
 
 namespace lld {
 class DefinedAtom;
-class MutableFile;
+class SimpleFile;
 
 namespace mach_o {
 
@@ -45,17 +46,17 @@ public:
   LayoutPass(const Registry &registry, SortOverride sorter);
 
   /// Sorts atoms in mergedFile by content type then by command line order.
-  void perform(std::unique_ptr<MutableFile> &mergedFile) override;
+  void perform(std::unique_ptr<SimpleFile> &mergedFile) override;
 
   virtual ~LayoutPass() {}
 
 private:
   // Build the followOn atoms chain as specified by the kindLayoutAfter
   // reference type
-  void buildFollowOnTable(MutableFile::DefinedAtomRange &range);
+  void buildFollowOnTable(SimpleFile::DefinedAtomRange &range);
 
   // Build a map of Atoms to ordinals for sorting the atoms
-  void buildOrdinalOverrideMap(MutableFile::DefinedAtomRange &range);
+  void buildOrdinalOverrideMap(SimpleFile::DefinedAtomRange &range);
 
   const Registry &_registry;
   SortOverride _customSorter;
@@ -83,12 +84,12 @@ private:
 
   void setChainRoot(const DefinedAtom *targetAtom, const DefinedAtom *root);
 
-  std::vector<SortKey> decorate(MutableFile::DefinedAtomRange &atomRange) const;
-  void undecorate(MutableFile::DefinedAtomRange &atomRange,
+  std::vector<SortKey> decorate(SimpleFile::DefinedAtomRange &atomRange) const;
+  void undecorate(SimpleFile::DefinedAtomRange &atomRange,
                   std::vector<SortKey> &keys) const;
 
   // Check if the follow-on graph is a correct structure. For debugging only.
-  void checkFollowonChain(MutableFile::DefinedAtomRange &range);
+  void checkFollowonChain(SimpleFile::DefinedAtomRange &range);
 };
 
 } // namespace mach_o

Modified: lld/trunk/lib/ReaderWriter/MachO/ShimPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ShimPass.cpp?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ShimPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ShimPass.cpp Tue Apr  7 15:43:38 2015
@@ -47,8 +47,7 @@ public:
     , _file("<mach-o shim pass>") {
   }
 
-
-  void perform(std::unique_ptr<MutableFile> &mergedFile) override {
+  void perform(std::unique_ptr<SimpleFile> &mergedFile) override {
     // Scan all references in all atoms.
     for (const DefinedAtom *atom : mergedFile->defined()) {
       for (const Reference *ref : *atom) {

Modified: lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp Tue Apr  7 15:43:38 2015
@@ -209,8 +209,7 @@ public:
     : _context(context), _archHandler(_context.archHandler()),
     _stubInfo(_archHandler.stubInfo()), _file("<mach-o Stubs pass>") { }
 
-
-  void perform(std::unique_ptr<MutableFile> &mergedFile) override {
+  void perform(std::unique_ptr<SimpleFile> &mergedFile) override {
     // Skip this pass if output format uses text relocations instead of stubs.
     if (!this->noTextRelocs())
       return;

Modified: lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.cpp?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.cpp Tue Apr  7 15:43:38 2015
@@ -78,7 +78,7 @@ static void assignOrdinals(PECOFFLinking
       desc.ordinal = nextOrdinal++;
 }
 
-static bool getExportedAtoms(PECOFFLinkingContext &ctx, MutableFile *file,
+static bool getExportedAtoms(PECOFFLinkingContext &ctx, SimpleFile *file,
                              std::vector<TableEntry> &ret) {
   std::map<StringRef, const DefinedAtom *> definedAtoms;
   for (const DefinedAtom *atom : file->defined())
@@ -135,7 +135,7 @@ EdataPass::createAddressTable(const std:
 edata::EdataAtom *
 EdataPass::createNamePointerTable(const PECOFFLinkingContext &ctx,
                                   const std::vector<TableEntry> &entries,
-                                  MutableFile *file) {
+                                  SimpleFile *file) {
   EdataAtom *table =
       new (_alloc) EdataAtom(_file, sizeof(uint32_t) * entries.size());
 
@@ -175,7 +175,7 @@ EdataPass::createOrdinalTable(const std:
   return ret;
 }
 
-void EdataPass::perform(std::unique_ptr<MutableFile> &file) {
+void EdataPass::perform(std::unique_ptr<SimpleFile> &file) {
   dedupExports(_ctx);
   assignOrdinals(_ctx);
 

Modified: lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.h?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.h Tue Apr  7 15:43:38 2015
@@ -66,7 +66,7 @@ public:
   EdataPass(PECOFFLinkingContext &ctx)
       : _ctx(ctx), _file(ctx), _is64(ctx.is64Bit()), _stringOrdinal(1024) {}
 
-  void perform(std::unique_ptr<MutableFile> &file) override;
+  void perform(std::unique_ptr<SimpleFile> &file) override;
 
 private:
   edata::EdataAtom *
@@ -80,7 +80,7 @@ private:
   edata::EdataAtom *
   createNamePointerTable(const PECOFFLinkingContext &ctx,
                          const std::vector<edata::TableEntry> &entries,
-                         MutableFile *file);
+                         SimpleFile *file);
 
   edata::EdataAtom *
   createOrdinalTable(const std::vector<edata::TableEntry> &entries,

Modified: lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp Tue Apr  7 15:43:38 2015
@@ -143,8 +143,8 @@ std::vector<uint8_t> DelayImportDirector
 
 // Find "___delayLoadHelper2 at 8" (or "__delayLoadHelper2" on x64).
 // This is not efficient but should be OK for now.
-static const Atom *
-findDelayLoadHelper(MutableFile &file, const PECOFFLinkingContext &ctx) {
+static const Atom *findDelayLoadHelper(SimpleFile &file,
+                                       const PECOFFLinkingContext &ctx) {
   StringRef sym = ctx.getDelayLoadHelperName();
   for (const DefinedAtom *atom : file.defined())
     if (atom->name() == sym)
@@ -287,7 +287,7 @@ DelayLoaderAtom::createContent(MachineTy
 
 } // namespace idata
 
-void IdataPass::perform(std::unique_ptr<MutableFile> &file) {
+void IdataPass::perform(std::unique_ptr<SimpleFile> &file) {
   if (file->sharedLibrary().empty())
     return;
 
@@ -324,8 +324,8 @@ void IdataPass::perform(std::unique_ptr<
   replaceSharedLibraryAtoms(*file);
 }
 
-std::map<StringRef, std::vector<COFFSharedLibraryAtom *> >
-IdataPass::groupByLoadName(MutableFile &file) {
+std::map<StringRef, std::vector<COFFSharedLibraryAtom *>>
+IdataPass::groupByLoadName(SimpleFile &file) {
   std::map<StringRef, COFFSharedLibraryAtom *> uniqueAtoms;
   for (const SharedLibraryAtom *atom : file.sharedLibrary())
     uniqueAtoms[atom->name()] =
@@ -340,7 +340,7 @@ IdataPass::groupByLoadName(MutableFile &
 }
 
 /// Transforms a reference to a COFFSharedLibraryAtom to a real reference.
-void IdataPass::replaceSharedLibraryAtoms(MutableFile &file) {
+void IdataPass::replaceSharedLibraryAtoms(SimpleFile &file) {
   for (const DefinedAtom *atom : file.defined()) {
     for (const Reference *ref : *atom) {
       const Atom *target = ref->target();

Modified: lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.h?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.h Tue Apr  7 15:43:38 2015
@@ -40,9 +40,9 @@ class ImportTableEntryAtom;
 
 // A state object of this pass.
 struct IdataContext {
-  IdataContext(MutableFile &f, VirtualFile &g, const PECOFFLinkingContext &c)
+  IdataContext(SimpleFile &f, VirtualFile &g, const PECOFFLinkingContext &c)
       : file(f), dummyFile(g), ctx(c) {}
-  MutableFile &file;
+  SimpleFile &file;
   VirtualFile &dummyFile;
   const PECOFFLinkingContext &ctx;
 };
@@ -195,13 +195,13 @@ class IdataPass : public lld::Pass {
 public:
   IdataPass(const PECOFFLinkingContext &ctx) : _dummyFile(ctx), _ctx(ctx) {}
 
-  void perform(std::unique_ptr<MutableFile> &file) override;
+  void perform(std::unique_ptr<SimpleFile> &file) override;
 
 private:
   std::map<StringRef, std::vector<COFFSharedLibraryAtom *>>
-  groupByLoadName(MutableFile &file);
+  groupByLoadName(SimpleFile &file);
 
-  void replaceSharedLibraryAtoms(MutableFile &file);
+  void replaceSharedLibraryAtoms(SimpleFile &file);
 
   // A dummy file with which all the atoms created in the pass will be
   // associated. Atoms need to be associated to an input file even if it's not

Modified: lld/trunk/lib/ReaderWriter/PECOFF/InferSubsystemPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/InferSubsystemPass.h?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/InferSubsystemPass.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/InferSubsystemPass.h Tue Apr  7 15:43:38 2015
@@ -22,7 +22,7 @@ class InferSubsystemPass : public lld::P
 public:
   InferSubsystemPass(PECOFFLinkingContext &ctx) : _ctx(ctx) {}
 
-  void perform(std::unique_ptr<MutableFile> &file) override {
+  void perform(std::unique_ptr<SimpleFile> &file) override {
     if (_ctx.getSubsystem() != WindowsSubsystem::IMAGE_SUBSYSTEM_UNKNOWN)
       return;
 

Modified: lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.cpp?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.cpp Tue Apr  7 15:43:38 2015
@@ -49,7 +49,7 @@ LoadConfigAtom::LoadConfigAtom(VirtualFi
 
 } // namespace loadcfg
 
-void LoadConfigPass::perform(std::unique_ptr<MutableFile> &file) {
+void LoadConfigPass::perform(std::unique_ptr<SimpleFile> &file) {
   if (_ctx.noSEH())
     return;
 

Modified: lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.h?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.h Tue Apr  7 15:43:38 2015
@@ -49,7 +49,7 @@ class LoadConfigPass : public lld::Pass
 public:
   LoadConfigPass(PECOFFLinkingContext &ctx) : _ctx(ctx), _file(ctx) {}
 
-  void perform(std::unique_ptr<MutableFile> &file) override;
+  void perform(std::unique_ptr<SimpleFile> &file) override;
 
 private:
   PECOFFLinkingContext &_ctx;

Modified: lld/trunk/lib/ReaderWriter/PECOFF/OrderPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/OrderPass.h?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/OrderPass.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/OrderPass.h Tue Apr  7 15:43:38 2015
@@ -55,8 +55,8 @@ static bool compare(const DefinedAtom *l
 
 class OrderPass : public lld::Pass {
 public:
-  void perform(std::unique_ptr<MutableFile> &file) override {
-    MutableFile::DefinedAtomRange defined = file->definedAtoms();
+  void perform(std::unique_ptr<SimpleFile> &file) override {
+    SimpleFile::DefinedAtomRange defined = file->definedAtoms();
     parallel_sort(defined.begin(), defined.end(), compare);
   }
 };

Modified: lld/trunk/lib/ReaderWriter/PECOFF/PDBPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/PDBPass.h?rev=234354&r1=234353&r2=234354&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/PDBPass.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/PDBPass.h Tue Apr  7 15:43:38 2015
@@ -21,7 +21,7 @@ class PDBPass : public lld::Pass {
 public:
   PDBPass(PECOFFLinkingContext &ctx) : _ctx(ctx) {}
 
-  void perform(std::unique_ptr<MutableFile> &file) override {
+  void perform(std::unique_ptr<SimpleFile> &file) override {
     if (_ctx.getDebug())
       touch(_ctx.getPDBFilePath());
   }





More information about the llvm-commits mailing list