[PATCH] D23437: [LoopInfo] Add a routine for verification by recomputation.

Michael Zolotukhin via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 31 12:42:02 PDT 2016


mzolotukhin added a comment.

Thanks, committed in r280280.

For DT recalculation we need to get `Function` from somewhere and I don't see an easy way to get it now. As for DT verification, it's possible, and I don't feel strong about either way, but slightly prefer keeping the stuff separate as we have an easy way to invoke each verifier both from command line and in the code.

Thanks,
Michael


================
Comment at: include/llvm/Analysis/LoopInfoImpl.h:535-541
@@ +534,9 @@
+static void
+addInnerLoopsToHeadersMap(DenseMap<BlockT *, const LoopT *> &LoopHeaders,
+                          const LoopInfoBase<BlockT, LoopT> &LI,
+                          const LoopT &L) {
+  LoopHeaders[L.getHeader()] = &L;
+  for (LoopT *SL : L)
+    addInnerLoopsToHeadersMap(LoopHeaders, LI, *SL);
+}
+
----------------
chandlerc wrote:
> Why not a lambda below? It wouldn't need to be a generic lambda as its already inside a function template and within that context you have specific types BlockT and LoopT already.
Can lambda be recursive?

================
Comment at: include/llvm/Analysis/LoopInfoImpl.h:544
@@ +543,3 @@
+template <class BlockT, class LoopT>
+static bool compareLoops(const LoopT *L1, const LoopT *L2) {
+  BlockT *H1 = L1->getHeader();
----------------
chandlerc wrote:
> Same question, why not a lambda?
Fixed.

================
Comment at: include/llvm/Analysis/LoopInfoImpl.h:549-552
@@ +548,6 @@
+    return false;
+  std::vector<BlockT *> BB1 = L1->getBlocks();
+  std::vector<BlockT *> BB2 = L2->getBlocks();
+  if (!compareVectors(BB1, BB2))
+    return false;
+
----------------
chandlerc wrote:
> std::sort and std::equals? Seems simpler and there is no order concern.
Done, thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D23437





More information about the llvm-commits mailing list