[llvm-dev] How a module pass can use analysis information?

Minghwa Wang via llvm-dev llvm-dev at lists.llvm.org
Mon Sep 19 10:53:31 PDT 2016


I am trying to write a llvm module pass by overriding the
runOnModule(Module &M), but my pass needs the RegioinInfo analysis to find
regions to get my pass working.

I tried to do the following in my module pass:
    RegionInfoPass RIP;
    if (RIP.runOnFunction(*F1)) {
      assert(false && "Failed to run runOnFunction");
    }
    RegionInfo *RI = &RIP.getAnalysis<RegionInfoPass>().getRegionInfo();
    RI->dump();
It compiles without problem, but when I run it, I got the following errors:
    AnalysisType&llvm::Pass::getAnalysis() const [with AnalysisType =
llvm::RegionInfoPass]:
    Assertion `Resolver && "Pass has not been inserted into a PassManager
object!"' failed.

I also tried to use RGPassManager as below:
    RGPassManager RGPM;
    if (RGPM.runOnFunction(*F1)) {
      assert(false && "Failed to run runOnFunction");
    }
Again, it compiles without problem, but when I run it, I got the same
errors as above.

Is anyone can show me what is the correct way for a module pass to use
RegionInfo analysis?

Thanks,
Ming-Hwa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160919/3d347433/attachment.html>


More information about the llvm-dev mailing list