I wrote my own in-tree LLVM pass using the new pass manager. I am now trying to run a sequence of other passes from within my pass before my pass goes on to do other things. My code that tries to run other passes looks something like this:
In this particular example, you’ll have to link against LLVMInstCombine. If you’re using CMake, you need to either add InstCombine to your LINK_COMPONENTS argument of add_llvm_library, or you need to use set(LLVM_LINK_COMPONENTS InstCombine) before your add_llvm_library line. This is, of course, assuming you have your own pass library defined via your own CMakeLists.txt file. If you’re modifying an existing one, you’ll have to make sure it links against InstCombine’s library.
That said, if you’re attempting to run the pass from inside another pass, creating an brand new FunctionAnalysisManager and trying to use it that way may result in some “analysis pass not registered” errors when you call run(). It’s better to pass the same manager your own pass uses since cross-registration has already occurred on that one.
I’m interested in this as well. For me, I’m trying out a couple of experiments, and wasn’t planning on committing anything upstream. Does anyone have any code pointers on how to achieve this? For me specifically, I’m trying to run function pipeline within a module pass. I see ModuleToFunctionPassAdaptor could be a potential clue into how to makeshift things around. But, if there is already a pattern or built-in support, that would be better. Also, I’m also developing in-tree if it makes anything easier.