[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 17:02:55 PST 2016


weimingz added inline comments.

================
Comment at: lib/IR/LegacyPassManager.cpp:90
@@ +89,3 @@
+                   cl::desc("Print IR only for specified functions"),
+                   cl::CommaSeparated);
+
----------------
joker.eph wrote:
> Just thought about this, we already have something to filter basic blocks in the DAG output, and the option is named `filter-view-dags`, so I feel this option should also start with `filter` for consistency. 
Agree. Will change it to -filter-print-funcs

================
Comment at: lib/IR/LegacyPassManager.cpp:129
@@ -112,2 +128,3 @@
+}
 /// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions
 /// or higher is specified.
----------------
joker.eph wrote:
> joker.eph wrote:
> > 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.
> To be more clear, I don't see why this wouldn't work:
> 
> ```
> bool llvm::isFunctionInPrintList(StringRef FunctionName) {
>   static std::unordered_set<std::string> PrintFuncNames(PrintFuncsList.begin(),
>                                                         PrintFuncsList.end());
> 
>   if (PrintFuncNames.empty())
>     return true;
> 
>   return PrintFuncNames.count(FunctionName);
> }
> ```
In Module print, we have 2 cases to handle now:
1. the default case / the filter list is empty():
   M.print(OS, nullptr, ShouldPreserveUseListOrder);  // this will dump all module info
2. the list is non empty. No GV, meta info will be output and only functions in the filter list will be printed. 

The code you show either dumps all funcs if list is empty or dump filtered funcs. But it doesn't differentiate case 1 and case 2.
   


Repository:
  rL LLVM

http://reviews.llvm.org/D15776





More information about the llvm-commits mailing list