Example of using RGPassManager?

Hi:
My pass needs to run on LLVM Regions, I’m currently using the following code


RGPassManager RPM;
RPM.add(createRegionPrinterPass());
RPM.doInitialization(M);
for (Function &func : M.functions()) {
RPM.runOnFunction(func);
}
RPM.doFinalization(M);

However when adding the pass, it asserts with PMTopLevelManager::findAnalysisUsage due to top level pass manager is null

Zhang

Probably it's because RegionPrinterPass also depends on a FunctionPass
analysis, such as DominatorTree. Try creating a function pass and
adding createRegionPrinterPass() to it, it will create the
RGPassManager for you.

Michael

Thanks. I ended up directly using legacy::PassManager which worked for me

Zhang