What's the go-to method to call other transform passes in LLVM9?

Hi:
In my in-house transform passes I needs to properly lower Switch/Invoke and PhiNodes, prior to LLVM9 I just call createLowerSwitchPass() and run it. However in LLVM9 doing this would assert out with error message:

Assertion failed: (Resolver && “Pass has not been inserted into a PassManager object!”), function getAnalysis, file \LLVM9/llvm/include/llvm/PassAnalysisSupport.h, line 221.

Is there any suggestion on this? And how do I make sure my transform passes in PassManagerBuilder are executed in a given order? Previously I create a dummy pass that calls the actual transform passes and run them in order, then inject this dummy pass into PMB

Hi:
In my in-house transform passes I needs to properly lower Switch/Invoke and PhiNodes, prior to LLVM9 I just call createLowerSwitchPass() and run it. However in LLVM9 doing this would assert out with error message:

Assertion failed: (Resolver && "Pass has not been inserted into a PassManager object!"), function getAnalysis, file \LLVM9/llvm/include/llvm/PassAnalysisSupport.h, line 221.

Is there any suggestion on this?

LowerSwitch requires the LazyValueInfo pass which it requests from the
pass manager. Since it is not part of a pass manager, you get the
error. I see two possibilities:
1. Just add the LowerSwitch pass after your pass to the pass manager.
2. Instantiate a pass manager inside out pass, add LowerSwitch to it,
and call the pass manager on the function. This will re-evaluate
LazyValueInfo even if the main pass manger already computed it.

And how do I make sure my transform passes in PassManagerBuilder are executed in a given order? Previously I create a dummy pass that calls the actual transform passes and run them in order, then inject this dummy pass into PMB

Passes on the same level are executed in the order they have been
added to the pass manager. Do you need a different order?

Michael

Reevaluating is not my concern since my transform passes likely broke them already anyway. Thanks!

Zhang

Hi:
I personally prefer method 2 in my use case, however, I currently modified PassManagerBuilder to inject my pass into the pipeline which means if I create another PassManagerBuilder in my pass it would be a deadloop.

Zhang