i am organizing my LLVM Passes into an Analysis Pass and a few Optimization Passes, which takes the result from analysis pass to guide their transformations.
I found a surprising pass type dependency between the analysis pass and optimization passes.
E.g.
Analysis-Pass Type Optimization-Pass Type Status in Optimization Pass when adding the Analysis Pass
Function Pass Function Pass Fine
Module Pass Module Pass Fine
Module Pass Function Pass Stuck
Function Pass Module Pass Stuck
Function Pass Loop Pass Stuck
Module Pass Loop Pass Stuck
...
The "stuck" situation happens when calling AU.addRequired<AnalysisPass>() inside the OptimizationPass's getAnalysisUsage() function.
The opt tool seems to run into an infinite loop (on trivial testcases, which should finish in a flash of a second).
Seems the Pass type between Analysis Pass and Optimization Pass has to match.
I wonder if this is documented somewhere?
Is there a simple rule to guide this?
E.g.
if the Optimization Pass needs to be a LoopPass, does it mean the AnalysisPass _has to_ be a Loop Pass as well?
Thank you
Chuck