Trevor Harmon
2010-Apr-01 22:37 UTC
[LLVMdev] AnalysisUsage: addRequired vs. addRequiredTransitive
On Mar 31, 2010, at 3:13 PM, Owen Anderson wrote:> Some analyses, like Andersen's AA, do all their computation in their > runOnFunction(). Therefore, anything they depended on can be > destroyed after the runOnFunction() returns.What about AA itself? Would addRequired<AliasAnalysis> keep AliasAnalysis alive (but allow AliasAnalysis's dependencies to die)?> Others, like MemoryDependenceAnalysis, are "lazy." MDA > specifically does NOT compute results in its runOnFunction(), > instead computing results on-demand when a user queries it. > Because MDA depends on AA, we must ensure that, as long as MDA is > alive and responding to queries, AA is alive as well. That is what > addRequiredTransitive does.I'm not sure if I follow this. So let's say I'm writing a pass Foo, and Foo depends on MDA. You're saying that Foo's getAnalysisUsage must call addRequiredTransitive< MemoryDependenceAnalysis>, not addRequired<MemoryDependenceAnalysis>, because otherwise the dependencies of Foo's dependencies might be destroyed. Do I have that right? Thanks, Trevor
Andreas Bolka
2010-Apr-01 23:59 UTC
[LLVMdev] AnalysisUsage: addRequired vs. addRequiredTransitive
On Fri Apr 02 00:37:03 +0200 2010, Trevor Harmon wrote:> On Mar 31, 2010, at 3:13 PM, Owen Anderson wrote: > > Others, like MemoryDependenceAnalysis, are "lazy." MDA > > specifically does NOT compute results in its runOnFunction(), > > instead computing results on-demand when a user queries it. Because > > MDA depends on AA, we must ensure that, as long as MDA is alive and > > responding to queries, AA is alive as well. That is what > > addRequiredTransitive does. > > I'm not sure if I follow this. So let's say I'm writing a pass Foo, > and Foo depends on MDA. You're saying that Foo's getAnalysisUsage must > call addRequiredTransitive< MemoryDependenceAnalysis>, not > addRequired<MemoryDependenceAnalysis>, because otherwise the > dependencies of Foo's dependencies might be destroyed. Do I have that > right?Nope. If Foo depends on MDA, then Foo does addRequired<MDA>(). But when Foo uses MDA, MDA itself needs AA. So MDA does addRequiredTransitive<AA>() as AA does not only need to be around within MDA's runOnFunction but also within each runOnFunction of a pass depending on MDA. So if MDA does addRequired<AA>, AA is only guaranteed to be alive for MDA's runOnFunction. If MDA does addRequiredTransitive<AA> instead, AA is not only alive for MDA's runOnFunction, but also for all runOnFunction-s of passes requiring MDA. Clear as mud? -- Regards, Andreas
Trevor Harmon
2010-Apr-02 00:40 UTC
[LLVMdev] AnalysisUsage: addRequired vs. addRequiredTransitive
On Apr 1, 2010, at 4:59 PM, Andreas Bolka wrote:> Nope. If Foo depends on MDA, then Foo does addRequired<MDA>(). But > when > Foo uses MDA, MDA itself needs AA. So MDA does > addRequiredTransitive<AA>() as AA does not only need to be around > within > MDA's runOnFunction but also within each runOnFunction of a pass > depending on MDA. > > So if MDA does addRequired<AA>, AA is only guaranteed to be alive for > MDA's runOnFunction. If MDA does addRequiredTransitive<AA> instead, AA > is not only alive for MDA's runOnFunction, but also for all > runOnFunction-s of passes requiring MDA.I get it now; thanks. By the way, how can I help put this MDA/AA example into the LLVM documentation? There are a lot of explanations like this that should be preserved in the docs someplace, but I don't know what the usual procedure is for getting them there. Trevor
Seemingly Similar Threads
- [LLVMdev] AnalysisUsage: addRequired vs. addRequiredTransitive
- [LLVMdev] AnalysisUsage: addRequired vs. addRequiredTransitive
- [LLVMdev] AnalysisUsage: addRequired vs. addRequiredTransitive
- [LLVMdev] addRequired vs addRequiredTransitive
- [LLVMdev] pass visibility question