[llvm-dev] Some questions about phase ordering in OPT and LLC
    serge guelton via llvm-dev 
    llvm-dev at lists.llvm.org
       
    Mon May  9 22:16:18 PDT 2016
    
    
  
> >> You can look at AddOptimizationPasses() in opt.cpp.
> > 
> > As far as I understand, the two passmanager do not interleave their
> > passes. It first runs all the function passes and below. Then all the
> > module passes. So if you specify:
> > 
> >    opt -mymodulepass0 -myfunctionpass -mymodulepass1
> > 
> > What you actually get is:
> > 
> > 1. myfunctionpass on each function
> > 2. mymodulepass0 
> > 3. mymodulepass0 
> 
> (I assume your 3 was intended to be mymodulepass1 right?)
(yes)
> So AFAIK no, you should get the order you specified on the command line, i.e. 
> 
> 1. mymodulepass0 
> 2. myfunctionpass on each function
> 3. mymodulepass1
MMMh, from opt.cpp, there's a first call to:
  if (OptLevelO1 || OptLevelO2 || OptLevelOs || OptLevelOz || OptLevelO3) {
    FPasses->doInitialization();
    for (Function &F : *M)
      FPasses->run(F);
    FPasses->doFinalization();
  }
then a few lines later, a call to:
    Passes.run(*M);
where Passes is the Module pass Manager and FPasses is the Function Pass
Manager. Each is filled in AddOptimizationPasses with different passes.
I don't see the point where the two manage interleave their passes.
    
    
More information about the llvm-dev
mailing list