[PATCH] D15776: Filtering IR printing for print-after-all/print-before-all

Weiming Zhao via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 5 12:31:07 PST 2016


weimingz marked 4 inline comments as done.

================
Comment at: lib/Analysis/CallGraphSCCPass.cpp:616
@@ +615,3 @@
+        if (CGN->getFunction()) {
+          if (isFunctionInPrintList(CGN->getFunction()->getName()))
+            CGN->getFunction()->print(Out);
----------------
tejohnson wrote:
> Combine above two ifs into a single "if (A && B)".
If we combine them, then for non-null function but not in our filter list,  it will output "Printing <null> Function"

================
Comment at: lib/Analysis/LoopPass.cpp:45
@@ -44,2 +44,3 @@
   bool runOnLoop(Loop *L, LPPassManager &) override {
-    P.run(*L);
+    if (L->getHeader() &&
+        isFunctionInPrintList(L->getHeader()->getParent()->getName()))
----------------
joker.eph wrote:
> What if we don't have a header? When does it happen? Can this inhibit the print of a loop even when `-print-funcs` isn't supplied?
> Else, could it be an assert instead?
normally we wouldn't hit this. 
But since there could be null blocks (see LoopInfo.cpp PrinterLoopPass::run() ), I added a check. If the code is broken, it should be caught by other passes. :D

 

================
Comment at: lib/IR/IRPrintingPasses.cpp:34
@@ -32,1 +33,3 @@
+  } else
+    OS << Banner << " (skipped printing)\n";
   return PreservedAnalyses::all();
----------------
tejohnson wrote:
> joker.eph wrote:
> > What about having the `else` here looping over the module and finding the functions selected to be printed and print them?
> Agree here with Mehdi. Rather than have an all-or-nothing printing of the module under a special "*" string, it would be better to walk the module and print just the functions in the list. Otherwise to get any printing before/after module passes you run into the same issue with huge amounts of output for large modules. This would also be analogous to what you are doing for SCC passes (printing just the functions in the SCC that are in the list).
Agree. I will add "*" to the list if we don't specify anything to filter. So by testing "*", we can tell if the Option is empty or not.
 For SCC, it already has a loop. 


Repository:
  rL LLVM

http://reviews.llvm.org/D15776





More information about the llvm-commits mailing list