Adding mem2reg pass to pass manager

Hi,

I want to add “mem2reg” pass similar to this:

PassManager PM;
PM.add(new LoopInfo());
PM.add(new Mem2Reg()); // What’s the class name for this pass

I couldn’t find the name of corresponding class and header file of mem2reg pass except “mem2reg.cpp”. So how can I add mem2reg pass into my pass manager?

Thanks,
Riyad

PM.add(createPromoteMemoryToRegisterPass()) works for me. Hope this helpful.

Thanks,

Xiangyang

Did you include "Mem2Reg.cpp"?

$ grep createPromoteMemoryToRegisterPass include -R
include/llvm/LinkAllPasses.h: (void) llvm::createPromoteMemoryToRegisterPass();
include/llvm/Transforms/Scalar.h:FunctionPass *createPromoteMemoryToRegisterPass();

It seem this should be enough: #include “llvm/Transforms/Scalar.h”