diff options
| author | Rui Ueyama <ruiu@google.com> | 2015-04-07 20:43:38 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2015-04-07 20:43:38 +0000 |
| commit | 3c45cffd68cd9839d4737ea260ed2706ab304cc9 (patch) | |
| tree | a9e98d63c888ff305a2683d6120ba195ccbed629 /lld/lib/ReaderWriter/MachO | |
| parent | 6bea2f4f88ddc4437c4a072ca60118e7ad8ed834 (diff) | |
| download | bcm5719-llvm-3c45cffd68cd9839d4737ea260ed2706ab304cc9.tar.gz bcm5719-llvm-3c45cffd68cd9839d4737ea260ed2706ab304cc9.zip | |
Merge MutableFile with SimpleFile.
SimpleFile is the only derived class of MutableFile.
This patch reduces the height of class hierarchy by removing
MutableFile class.
llvm-svn: 234354
Diffstat (limited to 'lld/lib/ReaderWriter/MachO')
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp | 8 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/GOTPass.cpp | 3 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/LayoutPass.cpp | 16 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/LayoutPass.h | 15 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/ShimPass.cpp | 3 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/StubsPass.cpp | 3 |
6 files changed, 23 insertions, 25 deletions
diff --git a/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp b/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp index e2037c354bc..3bef510ced8 100644 --- a/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp +++ b/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp @@ -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) { diff --git a/lld/lib/ReaderWriter/MachO/GOTPass.cpp b/lld/lib/ReaderWriter/MachO/GOTPass.cpp index 7dc7f0b9412..5e885c2c620 100644 --- a/lld/lib/ReaderWriter/MachO/GOTPass.cpp +++ b/lld/lib/ReaderWriter/MachO/GOTPass.cpp @@ -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) { diff --git a/lld/lib/ReaderWriter/MachO/LayoutPass.cpp b/lld/lib/ReaderWriter/MachO/LayoutPass.cpp index 2d096e4c1a6..de3d5c21db1 100644 --- a/lld/lib/ReaderWriter/MachO/LayoutPass.cpp +++ b/lld/lib/ReaderWriter/MachO/LayoutPass.cpp @@ -133,7 +133,7 @@ static void checkReachabilityFromRoot(AtomToAtomT &followOnRoots, } } -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 MutableFile::DefinedAtomRange &atomRange) { /// 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 DefinedAtom *targetAtom, /// 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(MutableFile::DefinedAtomRange &range) { /// 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(MutableFile::DefinedAtomRange &range) { } 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::DefinedAtomRange &atomRange) const { 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::DefinedAtomRange &atomRange, } /// 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); diff --git a/lld/lib/ReaderWriter/MachO/LayoutPass.h b/lld/lib/ReaderWriter/MachO/LayoutPass.h index 186f29be071..2b31e0eed3d 100644 --- a/lld/lib/ReaderWriter/MachO/LayoutPass.h +++ b/lld/lib/ReaderWriter/MachO/LayoutPass.h @@ -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 ®istry, 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 diff --git a/lld/lib/ReaderWriter/MachO/ShimPass.cpp b/lld/lib/ReaderWriter/MachO/ShimPass.cpp index a8c69f8ceac..8d53c230b7d 100644 --- a/lld/lib/ReaderWriter/MachO/ShimPass.cpp +++ b/lld/lib/ReaderWriter/MachO/ShimPass.cpp @@ -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) { diff --git a/lld/lib/ReaderWriter/MachO/StubsPass.cpp b/lld/lib/ReaderWriter/MachO/StubsPass.cpp index aac3a60cb43..5c4bb2cccf4 100644 --- a/lld/lib/ReaderWriter/MachO/StubsPass.cpp +++ b/lld/lib/ReaderWriter/MachO/StubsPass.cpp @@ -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; |

