diff options
| author | Nico Rieck <nico.rieck@gmail.com> | 2014-02-24 21:14:37 +0000 |
|---|---|---|
| committer | Nico Rieck <nico.rieck@gmail.com> | 2014-02-24 21:14:37 +0000 |
| commit | b9d84f4d14bc4db8abae30999d6beb64c3f8546a (patch) | |
| tree | c9c6298852e3570c541d3e90cd4aee131a4679a1 | |
| parent | 78f2b48e7d9a602e8f81f375f88b4bd4f4bad04a (diff) | |
| download | bcm5719-llvm-b9d84f4d14bc4db8abae30999d6beb64c3f8546a.tar.gz bcm5719-llvm-b9d84f4d14bc4db8abae30999d6beb64c3f8546a.zip | |
[lld] Include reference kind in cycle detector debug output
This restores the debug output to how it was before r197727 broke it. This
went undetected because the corresponding test was never run due to broken
feature detection.
llvm-svn: 202079
| -rw-r--r-- | lld/include/lld/Passes/LayoutPass.h | 5 | ||||
| -rw-r--r-- | lld/lib/Passes/LayoutPass.cpp | 20 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/CoreLinkingContext.cpp | 2 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp | 2 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp | 2 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp | 2 | ||||
| -rw-r--r-- | lld/test/core/layout-error-test.objtxt | 3 |
7 files changed, 24 insertions, 12 deletions
diff --git a/lld/include/lld/Passes/LayoutPass.h b/lld/include/lld/Passes/LayoutPass.h index 052653fd935..a5575bcca63 100644 --- a/lld/include/lld/Passes/LayoutPass.h +++ b/lld/include/lld/Passes/LayoutPass.h @@ -12,6 +12,7 @@ #include "lld/Core/File.h" #include "lld/Core/Pass.h" +#include "lld/ReaderWriter/Reader.h" #include "llvm/ADT/DenseMap.h" @@ -38,6 +39,8 @@ public: uint64_t _override; }; + LayoutPass(const Registry ®istry); + /// Sorts atoms in mergedFile by content type then by command line order. virtual void perform(std::unique_ptr<MutableFile> &mergedFile); @@ -59,6 +62,8 @@ private: // Build a map of Atoms to ordinals for sorting the atoms void buildOrdinalOverrideMap(MutableFile::DefinedAtomRange &range); + const Registry &_registry; + typedef llvm::DenseMap<const DefinedAtom *, const DefinedAtom *> AtomToAtomT; typedef llvm::DenseMap<const DefinedAtom *, uint64_t> AtomToOrdinalT; diff --git a/lld/lib/Passes/LayoutPass.cpp b/lld/lib/Passes/LayoutPass.cpp index d58fbcf3a96..a98fb8ab664 100644 --- a/lld/lib/Passes/LayoutPass.cpp +++ b/lld/lib/Passes/LayoutPass.cpp @@ -63,14 +63,21 @@ static std::string atomToDebugString(const Atom *atom) { return str; } -static void showCycleDetectedError(AtomToAtomT &followOnNexts, +static void showCycleDetectedError(const Registry ®istry, + AtomToAtomT &followOnNexts, const DefinedAtom *atom) { const DefinedAtom *start = atom; llvm::dbgs() << "There's a cycle in a follow-on chain!\n"; do { llvm::dbgs() << " " << atomToDebugString(atom) << "\n"; for (const Reference *ref : *atom) { - llvm::dbgs() << " " << atomToDebugString(ref->target()) << "\n"; + StringRef kindValStr; + if (!registry.referenceKindToString(ref->kindNamespace(), ref->kindArch(), + ref->kindValue(), kindValStr)) { + kindValStr = "<unknown>"; + } + llvm::dbgs() << " " << kindValStr + << ": " << atomToDebugString(ref->target()) << "\n"; } atom = followOnNexts[atom]; } while (atom != start); @@ -80,7 +87,8 @@ static void showCycleDetectedError(AtomToAtomT &followOnNexts, /// Exit if there's a cycle in a followon chain reachable from the /// given root atom. Uses the tortoise and hare algorithm to detect a /// cycle. -static void checkNoCycleInFollowonChain(AtomToAtomT &followOnNexts, +static void checkNoCycleInFollowonChain(const Registry ®istry, + AtomToAtomT &followOnNexts, const DefinedAtom *root) { const DefinedAtom *tortoise = root; const DefinedAtom *hare = followOnNexts[root]; @@ -88,7 +96,7 @@ static void checkNoCycleInFollowonChain(AtomToAtomT &followOnNexts, if (!tortoise || !hare) return; if (tortoise == hare) - showCycleDetectedError(followOnNexts, tortoise); + showCycleDetectedError(registry, followOnNexts, tortoise); tortoise = followOnNexts[tortoise]; hare = followOnNexts[followOnNexts[hare]]; } @@ -138,7 +146,7 @@ void LayoutPass::checkFollowonChain(MutableFile::DefinedAtomRange &range) { for (const auto &ai : _followOnRoots) roots.insert(ai.second); for (const DefinedAtom *root : roots) - checkNoCycleInFollowonChain(_followOnNexts, root); + checkNoCycleInFollowonChain(_registry, _followOnNexts, root); // Verify that all the atoms in followOnNexts have references to // their roots. @@ -247,6 +255,8 @@ static bool compareAtoms(const LayoutPass::SortKey &lc, return result; } +LayoutPass::LayoutPass(const Registry ®istry) : _registry(registry) {} + // Returns the atom immediately followed by the given atom in the followon // chain. const DefinedAtom *LayoutPass::findAtomFollowedBy( diff --git a/lld/lib/ReaderWriter/CoreLinkingContext.cpp b/lld/lib/ReaderWriter/CoreLinkingContext.cpp index 2e4d45dea48..31d8440b099 100644 --- a/lld/lib/ReaderWriter/CoreLinkingContext.cpp +++ b/lld/lib/ReaderWriter/CoreLinkingContext.cpp @@ -262,7 +262,7 @@ bool CoreLinkingContext::validateImpl(raw_ostream &) { void CoreLinkingContext::addPasses(PassManager &pm) { for (StringRef name : _passNames) { if (name.equals("layout")) - pm.add(std::unique_ptr<Pass>((new LayoutPass()))); + pm.add(std::unique_ptr<Pass>(new LayoutPass(registry()))); else if (name.equals("GOT")) pm.add(std::unique_ptr<Pass>(new TestingGOTPass(*this))); else if (name.equals("stubs")) diff --git a/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp b/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp index c3b68909311..63ae3f4b30f 100644 --- a/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp +++ b/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp @@ -54,7 +54,7 @@ bool ELFLinkingContext::isLittleEndian() const { void ELFLinkingContext::addPasses(PassManager &pm) { if (_runLayoutPass) - pm.add(std::unique_ptr<Pass>(new LayoutPass())); + pm.add(std::unique_ptr<Pass>(new LayoutPass(registry()))); pm.add(std::unique_ptr<Pass>(new elf::ArrayOrderPass())); } diff --git a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp index cb8740d1e10..5bd9a5e5df6 100644 --- a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp +++ b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp @@ -295,7 +295,7 @@ void MachOLinkingContext::addPasses(PassManager &pm) { pm.add(std::unique_ptr<Pass>(new mach_o::GOTPass)); pm.add(std::unique_ptr<Pass>(new mach_o::StubsPass(*this))); } - pm.add(std::unique_ptr<Pass>(new LayoutPass())); + pm.add(std::unique_ptr<Pass>(new LayoutPass(registry()))); } Writer &MachOLinkingContext::writer() const { diff --git a/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp b/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp index c727ab8df58..c38c4aef878 100644 --- a/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp +++ b/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp @@ -262,7 +262,7 @@ void PECOFFLinkingContext::addPasses(PassManager &pm) { pm.add(std::unique_ptr<Pass>(new pecoff::SetSubsystemPass(*this))); pm.add(std::unique_ptr<Pass>(new pecoff::EdataPass(*this))); pm.add(std::unique_ptr<Pass>(new pecoff::IdataPass(*this))); - pm.add(std::unique_ptr<Pass>(new LayoutPass())); + pm.add(std::unique_ptr<Pass>(new LayoutPass(registry()))); pm.add(std::unique_ptr<Pass>(new pecoff::GroupedSectionsPass())); } diff --git a/lld/test/core/layout-error-test.objtxt b/lld/test/core/layout-error-test.objtxt index 5cb6b69a1dc..c9594d28f98 100644 --- a/lld/test/core/layout-error-test.objtxt +++ b/lld/test/core/layout-error-test.objtxt @@ -2,9 +2,6 @@ # RUN: not lld -core --add-pass layout -mllvm -debug-only=LayoutPass \ # RUN: %s 2> %t.err # RUN: FileCheck %s -check-prefix=CHECK < %t.err -# FIXME: This test broke because it was never run, and lld's debug output is -# now missing the kind of the references. -# XFAIL: * --- defined-atoms: |

