call an existing IPO pass


I found an existing pass “CalledValuePropagation” that can solve the problem I raised a few days ago regarding the “callees” metadata (!topic/llvm-dev/yjtZVMH_aC4). Now I have difficulty in calling this pass in my own pass.

In my own pass, I called


and in the “getAnalysisUsage(AnalysisUsage &AU)” function, I called

I got compilation errors:

It will be a great help if anyone can point out how to call the

"CalledValuePropagationPass" in my own pass

You cant call passes from passes.
You can only organize a pipeline, so passes are being run in succession.
Just add CVP into pass manager before your own pass and you should be fine.

Also, passes are not analyses and doing AU.addRequired on a pass is not a good idea
(though sometimes this hack might seem to work).


Generally, passes are viewed as rather independent transformations of IR,
so they can be run in any order w/o breaking correctness of transformations.
(there are exceptions to that but they are, well, exceptions).

If you need a particular order of passes for correctness of your pass then
you better reconsider if ever possible.

Yet, as you might imagine, the order of passes matters for the quality of optimizations.
And thats where Pass Manager comes into play, as it controls all the aspects of passes execution.
So if you need a particular order of passes for the - you set up your Pass Manager appropriately.
With “opt” the order in which it adds passes to Pass Manager is determined by the order of
command-line pass options:
opt -cvp -your-pass
will execute first cvp and then your pass.