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 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 comes before any manually specified passes in the argument list. Anyone knows if this is intentional and if so, why?
Regards,
Jesper