[LLVMdev] addRequired vs addRequiredTransitive

Chris Lattner sabre at nondot.org
Sat Oct 21 22:40:24 PDT 2006


On Sat, 21 Oct 2006, Ryan M. Lefever wrote:
> I am having a hard time figuring out the difference between addRequired
> and addRequiredTransitive.  Could someone please clarify the difference?
>  Let's say I have a function pass P1 that relies on a function pass P2.
> P1 computes some sort of analysis on a function F and P2 uses that
> analysis when it processes F.  Does that mean that I should use
> addRequiredTransitive?

An analysis pass has two interesting stages:

1. When it's runOnFunction (or whatever) method is called.  Call this the
    'computation' phase of an analysis.
2. After its computation phase when some other pass is using it.

If you are writing some analysis A that needs analysis B, you use one of 
these two methods.  Use addRequired if A uses B in phase #1.  Use 
addRequiredTransitive if A uses B in phase #1 or phase #2.

If this helps, I'd appreciate it if you would create a doc patch to 
improve the how-to-write-a-pass document with something that would have 
helped you to understand the situation better.

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/



More information about the llvm-dev mailing list