<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 10, 2015 at 11:43 AM, Daniel Berlin <span dir="ltr"><<a href="mailto:dberlin@dberlin.org" target="_blank">dberlin@dberlin.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Thu, Dec 10, 2015 at 11:27 AM, Larisse Voufo <span dir="ltr"><<a href="mailto:lvoufo@gmail.com" target="_blank">lvoufo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">lvoufo added a comment.<br>
<span><br>
In <a href="http://reviews.llvm.org/D15124#307279" rel="noreferrer" target="_blank">http://reviews.llvm.org/D15124#307279</a>, @dberlin wrote:<br>
<br>
> "(2) -gvn already requires -basicaa. So, -basicaa would be redundant in<br>
>  '-basicaa -gvn'. I could add it for clarity if you prefer.<br>
>  "<br>
>  -gvn does not require -basicaa.<br>
>  You've stated this a few times, and i'm not sure why you think this.<br>
><br>
> <from GVN>:<br>
><br>
>   void getAnalysisUsage(AnalysisUsage &AU) const override {<br>
>         AU.addRequired<AssumptionCacheTracker>();<br>
>         AU.addRequired<DominatorTreeWrapperPass>();<br>
>         AU.addRequired<TargetLibraryInfoWrapperPass>();<br>
>         if (!NoLoads)<br>
>           AU.addRequired<MemoryDependenceAnalysis>();<br>
>         AU.addRequired<AAResultsWrapperPass>();<br>
><br>
><br>
> }<br>
><br>
> GVN requires AC, DominatorTree, and TLI all the time.<br>
>  It uses AA results, which is "whatever aa you have enabled".<br>
>  It requires memorydependence if you want to optimize loads.<br>
>  Memory dependence, in turn, does not require basicaa either:<br>
><br>
> void MemoryDependenceAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {<br>
><br>
>     AU.setPreservesAll();<br>
>     AU.addRequired<AssumptionCacheTracker>();<br>
>     AU.addRequiredTransitive<AAResultsWrapperPass>();<br>
>     AU.addRequiredTransitive<TargetLibraryInfoWrapperPass>();<br>
>   }<br>
><br>
><br>
><br>
> No passes *require* basicaa, because basicaa is an optional pass providing<br>
>  AA results.<br>
<br>
<br>
</span>Point taken. I may be misusing "require" here, but I sure understand what is going on better now thanks to this.<br>
To clarify my statements and for added clarity from your points above, I have 2 questions:<br>
<br>
1 - What is one to make of the dependence on `BasicAAWrapperPass` in the following?<br>
<br>
  INITIALIZE_PASS_BEGIN(AAResultsWrapperPass, "aa",<br>
                        "Function Alias Analysis Results", false, true)<br>
  INITIALIZE_PASS_DEPENDENCY(BasicAAWrapperPass)<br>
  INITIALIZE_PASS_DEPENDENCY(CFLAAWrapperPass)<br>
  INITIALIZE_PASS_DEPENDENCY(ExternalAAWrapperPass)<br>
  INITIALIZE_PASS_DEPENDENCY(GlobalsAAWrapperPass)<br>
  INITIALIZE_PASS_DEPENDENCY(ObjCARCAAWrapperPass)<br>
  INITIALIZE_PASS_DEPENDENCY(SCEVAAWrapperPass)<br>
  INITIALIZE_PASS_DEPENDENCY(ScopedNoAliasAAWrapperPass)<br>
  INITIALIZE_PASS_DEPENDENCY(TypeBasedAAWrapperPass)<br>
  INITIALIZE_PASS_END(AAResultsWrapperPass, "aa",<br>
                      "Function Alias Analysis Results", false, true)<br>
<br>
So far as I understand, this *will* initialize a `BaiscAAWrapperPass` pass which, when run (either via `run()` or `runOnFunction()`), will build a `BasicAAResult` object.<br></blockquote></div></div><div><br>None of these wrapper passes do anything in their runOnFunction.</div><div>The resulting result object does nothing unless it is added by the aaresultswrapperpass to the aa results.</div><div><br></div><div>See aaresultswrapperpass::runOnFunction.</div></div></div></div></blockquote><div><br></div><div>Okay. So here's the interesting part from AAResultsWrapperPass::runOnFunction:</div><div>...</div><div>  // BasicAA is always available for function analyses. Also, we add it first</div><div>  // so that it can trump TBAA results when it proves MustAlias.</div><div>  // FIXME: TBAA should have an explicit mode to support this and then we</div><div>  // should reconsider the ordering here.</div><div>  if (!DisableBasicAA)</div><div>    AAR->addAAResult(getAnalysis<BasicAAWrapperPass>().getResult()); </div><div>...</div><div><br></div><div>Unless basic AA is disabled (via `DisableBasicAA`), the result from the `BasicAAWrapperPass` is added to the AA results.</div>`DisableBasicAA` is false by default, and `opt -disable-basicaa -gvn` *does not* eliminate loads that `opt -gvn` does (that depend on -basicaa).</div><div class="gmail_quote"><br></div><div class="gmail_quote">To your point, the `BasicAAWrapperPass` pass is initialized, and a basic AA result object is created, regardless of whether basic AA is (explicitly) disabled (e.g. via -disable-basicaa). Then, basic AA results only have an effect in -gvn if basic AA is not disabled---which is the default behavior. Right?</div><div class="gmail_quote"><div><br></div><div>So, it seems fair to say that "-gvn *requires* -basicaa for our load elimination purposes (which depend on basic AA)". Wouldn't you say?</div><div>Or would *depends on* (or else), instead of *requires*, be more accurate?</div><div>It is however true that simply saying "-gvn *requires* -basicaa" without the added qualifiers is not entirely true, as -gvn would still function without basic AA, but without eliminating our loads.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><div><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
2 - There does not seem to be a difference between `opt -gvn` and `opt -basicaa -gvn`. In fact, running `opt -gvn -debug-pass=Arguments` and  `opt -basicaa -gvn -debug-pass=Arguments` both return the following, where -basicaa is automatically added.<br>
<br>
  Pass Arguments:  -targetlibinfo -tti -assumption-cache-tracker -invariant-info-marker -basicaa -domtree -aa -memdep -gvn -verify<br></blockquote><div><br></div><div><br></div></span><div>Starting at the new AAResultsWrapperPass, it looks like this changed the default to require basicaa on August 17th (intentionally or not).</div></div></div></div></blockquote><div><br></div><div>Indeed, running `opt -gvn -debug-pass=Arguments -disable-basicaa` produces the exact same output as `opt -gvn -debug-pass=Arguments`, with the disabled effect in -gvn only being visible in the output program. </div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>--Dan</div></div></div></div>
</blockquote></div><br></div></div>