[PATCH] D74691: [Attributor] add some pattern to containsCycle

Stefanos Baziotis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 18 10:25:47 PST 2020


baziotis added inline comments.


================
Comment at: llvm/lib/Transforms/IPO/Attributor.cpp:2376-2380
+        A.getInfoCache().getAnalysisResultForFunction<ScalarEvolutionAnalysis>(
+            F);
+    LoopInfo *LI =
+        A.getInfoCache().getAnalysisResultForFunction<LoopAnalysis>(F);
+    if (!LI || !SE) continue;
----------------
jdoerfert wrote:
> baziotis wrote:
> > I believe you can get all those (LI, SE and their tests for null) out (i.e. before) of the loop, I don't think they can change.
> Yes. But you also cannot `continue` if LI or SE is null. If you don't have those analysis you need to be conservative about the result.
True and in the case that either of them is null, I think it will still be faster to work with SCCs rather than falling back to the old version.
Specifically, the SCC iterator is lazy. That is, it gets you an SCC when you ask for it, which in your case is either in the beginning or in the `++` of the iterator (Check: https://llvm.org/doxygen/SCCIterator_8h_source.html#l00117. You can see that it calls `GetNextSCC()` which does the job of getting the next SCC. This is done every time you `++` it).

So, in summary, check if you have any SCC at all and if yes, return true.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74691/new/

https://reviews.llvm.org/D74691





More information about the llvm-commits mailing list