How to move legacy passes to new pass manager?

I synced up my local llvm repo to upstream 14.0.0 release and some of my custom passes that I added into IPO\PassManagerBuilder.cpp doesn’t work unless I specify -Xclang -fno-experimental-new-pass-manager. Could someone give me some pointers on how to transition to use new pass manager?

Hi,

Please see

https://llvm.org/docs/NewPassManager.html
https://llvm.org/docs/WritingAnLLVMNewPMPass.html

Cheers

1 Like

Thanks! I found what I was looking for.

"That’s it for the pass itself. Now in order to “register” the pass, we need to add it to a couple places. Add the following to llvm/lib/Passes/PassRegistry.def in the FUNCTION_PASS section

FUNCTION_PASS(“helloworld”, HelloWorldPass())

… which adds the pass under the name “helloworld”.

llvm/lib/Passes/PassRegistry.def is #include’d into llvm/lib/Passes/PassBuilder.cpp multiple times for various reasons. Since it constructs our pass, we need to also add the proper #include in llvm/lib/Passes/PassBuilder.cpp:

#include “llvm/Transforms/Utils/HelloWorld.h”

This should be all the code necessary for our pass, now it’s time to compile and run it."