[LLVMdev] Pass vs. FunctionPass

Vladimir Prus ghost at cs.msu.su
Thu Jun 24 08:39:02 PDT 2004


I wonder in what cases FunctionPass is better that Pass. For example, 
addPassesToEmitAssembly takes PassManger and addPassesToJITCompile takes 
FunctionPassManager.

Another question is about FunctionPassManager::run(Function&) and 
FunctionPass(Function&). The former calls the later, which is fine, but the 
latter looks like this:

bool FunctionPass::run(Function &F) {
  if (F.isExternal()) return false;// Passes are not run on external 
functions!

  return doInitialization(*F.getParent()) | runOnFunction(F)
       | doFinalization(*F.getParent());
}

So, with FunctionPassManager, doInitializaton will be called once for each 
function, which is strange, given that that method takes Module&. When this 
behaviour is desirable?

- Volodya




More information about the llvm-dev mailing list