[llvm-dev] opt function passes swallowed

Jesper Antonsson via llvm-dev llvm-dev at lists.llvm.org
Thu Apr 21 07:32:42 PDT 2016


Hi,

I've observed that FunctionPasses are not run when a specific argument order is handed to opt. I.e. when I specify:
opt -O3 -float2int file.ll

... the FunctionPasses specified by populateFunctionPasses() are not run. However, if I put the -O3 after all manually specified passes, then the FunctionPasses are run:
opt -float2int -O3 file.ll

In the code (opt.cpp), we are explicitly checking the argument order (somewhere around line 537 for me):
    if (OptLevelO3 && OptLevelO3.getPosition() < PassList.getPosition(i)) {
      AddOptimizationPasses(Passes, *FPasses, 3, 0);
      OptLevelO3 = false;
    }

Note that we set OptLevelO3 to false above. Later, we run FPasses only if some OptLevelO<n> is true:
  if (OptLevelO1 || OptLevelO2 || OptLevelOs || OptLevelOz || OptLevelO3) {
    FPasses->doInitialization();
    for (Function &F : *M)
      FPasses->run(F);
    FPasses->doFinalization();
  }

Thus FPasses are not run if -O<n> comes before any manually specified passes in the argument list. Anyone knows if this is intentional and if so, why?
Regards,
Jesper
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160421/87e53bc0/attachment.html>


More information about the llvm-dev mailing list