GetAnalysis() failing with required passes


I’m working with an old project that has a bunch of custom passes, and trying to get it to run with the most recent version of the flang LLVM compiler.

I’ve upgraded the project to use the flang llvm fork (approx. LLVM 7.1) from 3.0 and gotten it to compile, but am running into an issue with pass registration and getAnalysis().

Specifically, the pass ‘Operators’ needs to call getAnalysis() on a ‘ParseConfig’ pass to continue;

ParseConfig &parseConfig = getAnalysis();

but fails an assertion with;

"AnalysisType& llvm::Pass::getAnalysisID(llvm::AnalysisID) const [with AnalysisType = ParseConfig; llvm::AnalysisID = const void*]: Assertion `ResultPass && “getAnalysis*() called on an analysis that was not " “‘required’ by pass!”’ failed.”

I’ve sorted through every google search I can and all the llvm library calls to try and fix this. The following is true;

  • Both Operators and ParseConfig passes inherit from ModulePass
  • Operators overrides getAnalysisUsage() and adds ParseConfig as required.
  • ParseConfig correctly calls the RegisterPass<> template and is registered.
  • I’ve tried using RegisterStandardPasses() as described here: and the code is run, but the assertion still fails.
  • I’ve stepped through the registration of ParseConfig with GDB and it registers successfully, and I’ve stepped through the getAnalysis() call from Operators and the assertion fails at AnalysisResolver::findImplPass(), as the AnalysisImpls list is always empty ( this is the 10.0 code, but the library is the same as the flang LLVM.

One thing I haven’t fully figured out is how both passes inheriting from ModulePass affects this. Most people who have had this issue have simply been trying to use a Function pass in a module pass class or something similar, but all I need is all the info gathered from the previous ParseConfig pass to start working in the Operators pass, and both are done on a module level.

I’m pretty much at a loss at this point. If anyone is well versed with pass registration and getAnalysis that could provide some insight, I’d greatly appreciate it. I can also provide more information as needed.


  • Trevor