Using other Pass info in current Pass
For the Pass Manager to work optimally it needs to know the dependencies between the Passes. Each of the passes can itself declare its dependencies: the analysis passes that need to be executed before this pass is executed and the passes that will get invalidated after the current pass is run. To specify these dependencies, a pass needs to implement the getAnalysisUsage
method.
virtual void getAnalysisUsage(AnalysisUsage &Info) const;
Using this method the current pass can specify the required and invalidated sets by filling in the details in the AnalysisUsage
object. To fill in the information the Pass needs to call any of the following methods:
AnalysisUsage::addRequired<> method
This method arranges for the execution of a Pass prior to the current Pass. One example of this is: for memory copy optimization it needs the results of an alias analysis:
void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequired<AliasAnalysis>...