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

Mehdi AMINI via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 5 16:14:00 PST 2016


joker.eph added inline comments.

================
Comment at: lib/Analysis/LoopPass.cpp:45-48
@@ -44,4 +44,6 @@
   bool runOnLoop(Loop *L, LPPassManager &) override {
-    P.run(*L);
+    if (L->getHeader() &&
+        isFunctionInPrintList(L->getHeader()->getParent()->getName()))
+      P.run(*L);
     return false;
   }
----------------
I see, but it means that here we shouldn't check for the header but get the first valid block to get the function, something like:

```
auto FirstValidBlockInLoop = std::find_if(L.blocks().start(), L.blocks().end(), [] (BasicBlock *Block) { return Block; });
if (FirstValidBlockInLoop != L.blocks().end() && 
    isFunctionInPrintList(FirstValidBlockInLoop->getParent()->getName()))
      P.run(*L);
```

================
Comment at: lib/IR/LegacyPassManager.cpp:129
@@ -112,2 +128,3 @@
+}
 /// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions
 /// or higher is specified.
----------------
weimingz wrote:
> Module printing is different. It not just prints each functions but also others like meta, GV, triple, etc. By default (not specify anything on the filter list), it should print all those stuff.
> 
> So we need two functionalities: 1) tell if some function is in list or not; 2) tell if we specified anything to the list.  
You don't need to add `"*"` to the set to have the empty case working since in the empty case true is returned for anything.


Repository:
  rL LLVM

http://reviews.llvm.org/D15776





More information about the llvm-commits mailing list