[LLVMdev] questions about getAnalysisUsage

John Criswell jtcriswel at gmail.com
Mon Sep 29 15:53:23 PDT 2014


On 9/29/14, 5:51 PM, songlh wrote:
> Hi,
>
>   I notice that there are several different methods called inside 
> getAnalysisUsage(). The parameters of addRequiredID and addPreservedID 
> are passID. What is the difference between Required and Preserved? 

A Required pass is one that must be run before the pass requiring it.  
The required pass is an analysis pass that your pass will query for 
analysis information.  This information is used by the PassManager to 
determine which analysis passes must be run before another analysis or 
optimization pass.


A Preserved pass is an analysis pass whose analysis results your pass 
does not modify.  For example, a pass may modify the code in a way that 
does not modify the results of a dominator analysis.  The PassManager 
uses this information to avoid rerunning expensive analyses unnecessarily.

> There are also function named addRequired<PassName>() called. What is 
> the difference between addRequired<PassName>() and addRequiredID(PassID)?

I suspect that addRequired<PassName>() and addRequiredID() do the same 
thing but have different inputs.  When writing a pass, you should just 
use addRequired<PassName>(); I've never seen anyone use addRequiredID().

Regards,

John Criswell




More information about the llvm-dev mailing list