[PATCH] [LayoutPass] Add a method to check the followon graph structure.

Shankar Kalpathi Easwaran shankarke at gmail.com
Wed Jun 5 18:16:10 PDT 2013



================
Comment at: lib/ReaderWriter/ELF/Atoms.h:484-488
@@ -483,2 +483,7 @@
 
+  std::string toDebugString() const {
+    std::string name = DefinedAtom::toDebugString();
+    return name + " in " + _sectionName.str();
+  }
+
 private:
----------------
Rui Ueyama wrote:
> Shankar Kalpathi Easwaran wrote:
> > should be moved to LayoutPass, you can call toDebugString(Atom) and have this function in the LayoutPass.
> > 
> So toDebugString()'s signature should be toDebugString(const DefinedAtom *), and it dyn_cast the argument to ELFDefinedAtom, right? I tried that and found that there seems no easy way to do that, because ELFDefinedAtom<ELFT> is template class and there's no easy way to know what ELFT type is in the layout pass. Am I missing something?
Since you need only the name, you can access that using DefinedAtom * itself.

================
Comment at: lib/Passes/LayoutPass.cpp:475-493
@@ +474,21 @@
+
+/// Verify that the followon chain is sane. Should not be called in
+/// release binary.
+void LayoutPass::checkFollowonChain(MutableFile::DefinedAtomRange &range) {
+  ScopedTask task(getDefaultDomain(), "LayoutPass::checkFollowonChain");
+
+  // Verify that there's no cycle in follow-on chain.
+  std::set<const DefinedAtom *> roots;
+  for (const auto &ai : _followOnRoots)
+    roots.insert(ai.second);
+  for (const DefinedAtom *root : roots)
+    checkNoCycleInFollowonChain(_followOnNexts, root);
+
+  // Verify that all the atoms in followOnNexts have references to
+  // their roots.
+  for (const auto &ai : _followOnNexts) {
+    checkReachabilityFromRoot(_followOnRoots, ai.first);
+    checkReachabilityFromRoot(_followOnRoots, ai.second);
+  }
+}
+
----------------
Shankar Kalpathi Easwaran wrote:
> all of the code that shouldnt be in release build should be in 
> 
> ifndef NDEBUG
?


http://llvm-reviews.chandlerc.com/D922



More information about the llvm-commits mailing list