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

Rui Ueyama ruiu at google.com
Wed Jun 5 16:24:57 PDT 2013



================
Comment at: lib/Passes/LayoutPass.cpp:423-425
@@ +422,5 @@
+
+// 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.
+void checkNoCycleInFollowonChain(AtomToAtomT &followOnNexts,
----------------
Shankar Kalpathi Easwaran wrote:
> doxygen ?
done.

================
Comment at: lib/Passes/LayoutPass.cpp:412-415
@@ +411,6 @@
+      std::string refstr = ref->target()->toDebugString();
+      if (ref->kind() == lld::Reference::kindLayoutBefore) {
+        llvm::dbgs () << "    layout-before: " << refstr << "\n";
+      } else if (ref->kind() == lld::Reference::kindLayoutAfter) {
+        llvm::dbgs () << "    layout-after: " << refstr << "\n";
+      }
----------------
Shankar Kalpathi Easwaran wrote:
> not handling In-Group references.
done.

================
Comment at: lib/Passes/LayoutPass.cpp:426-438
@@ +425,15 @@
+// cycle.
+void checkNoCycleInFollowonChain(AtomToAtomT &followOnNexts,
+                                 const DefinedAtom *root) {
+  const DefinedAtom *tortoise = root;
+  const DefinedAtom *hare = followOnNexts[root];
+  while (true) {
+    if (!tortoise || !hare)
+      return;
+    if (tortoise == hare)
+      showCycleDetectedError(followOnNexts, tortoise);
+    tortoise = followOnNexts[tortoise];
+    hare = followOnNexts[followOnNexts[hare]];
+  }
+}
+
----------------
Shankar Kalpathi Easwaran wrote:
> can all these functions be const ?
I tried but I failed, as there's no const-qualified DenseMap[] defined.

================
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:
----------------
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?


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



More information about the llvm-commits mailing list