PassManager vs. FunctionPassManager

The opt tool uses two helpers to run passes:
createStandardFunctionPasses and createStandardModulePasses. How were
the passes to be instantiated by each function chosen? There are some
FunctionPasses instantiated by createStandardModulePasses which is a
bit counterintuitive.

I see that all passes added by the user on the command line are added
to "Passes" in opt, meaning they're added to the same pass manager
as the passes in createStandardModulePasses.

What's the point of having two pass managers here? Why not just use
"Passes" for everything?

Thanks for the insight.

                         -Dave

This is done to replicate what llvm-gcc does. First pass manager to
optimizer each function individually at the end of the function.
Second pass manager to optimize entire module. Add
-fdebug-pass-arguments on the llvm-gcc command line for more info.

What's the point of having two pass managers here? Why not just use
"Passes" for everything?

This is done to replicate what llvm-gcc does. First pass manager to
optimizer each function individually at the end of the function.
Second pass manager to optimize entire module. Add
-fdebug-pass-arguments on the llvm-gcc command line for more info.

I always assumed that the per-function passes, which are run on each
function when it is generated, are there to reduce the size of the
bitcode, enabling llvm-gcc to handle larger compile units.

Ciao,

Duncan.