[llvm-dev] What's the go-to method to call other transform passes in LLVM9?

Michael Kruse via llvm-dev llvm-dev at lists.llvm.org
Fri Dec 20 02:32:19 PST 2019


Am Fr., 20. Dez. 2019 um 07:24 Uhr schrieb Zhang via llvm-dev
<llvm-dev at lists.llvm.org>:
>
> 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


More information about the llvm-dev mailing list