How to make a function pass run before inlining

Hi all,

I wanted to have an LLVM pass to inject code inside functions matching some conditions about function signatures. If inlining happens before the LLVM pass, it may not find all functions.

Is it possible to always run a pass before inlining?

It seems that LLVM schedules passes in terms of the orders they are added into Pass Manager.
Do we have any examples to use Pass Manager to control order?

Thank you,

Does help?

Thank you! I guess using registerPipelineStartEPCallback at BackendUtil.cpp.

These PassBuilder register callbacks have an optimization level argument. Does each level have its own pipeline, and each pipeline would call this callback individually?