[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:48:37 PST 2016


weimingz added inline comments.

================
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:
> > > 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.
> > >    
> > What about:
> > 
> > ```
> > 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) || PrintFuncNames.count("*");
> > }
> > ```
> > 
> Nevermind forget my last comment, I still don't see any use for that. I still don't get your use case.
> 
> Can you provide an input where it differs?
For example, when the filter-list is empty. the whole module info is expected.
So in lib/IR/IRPrintingPasses.cpp, we should call 
    M.print(...);

The loop below should be run only when the filter list is not empty:
   for(const auto &F : M.functions())
    if (llvm::isFunctionInPrintList(F.getName()))  // Although it can return T if filter list is empty, but we don't want to just print function level IRs
        F.print(OS);


Repository:
  rL LLVM

http://reviews.llvm.org/D15776





More information about the llvm-commits mailing list