[PATCH] D38862: Add must alias info to ModRefInfo.

Hal Finkel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 25 20:12:56 PDT 2017


hfinkel added inline comments.


================
Comment at: lib/Analysis/AliasAnalysis.cpp:151
+    if (MR & MRI_ModRef)
+      return ModRefInfo(MRI_ModRef | (MR & MRI_Must));
   }
----------------
dberlin wrote:
> hfinkel wrote:
> > How is including MR's Must bit useful? What if the call has multiple pointer-typed arguments?
> See below.
> If you are trying to move a call, knowing that another call mustaliases everything you do, means that  you don't have to give up and not move it. you can instead try to move it as well.
That makes sense. MRI_Must on a call will mean that all operands must alias. We should make that clear in the documentation.


================
Comment at: lib/Analysis/BasicAliasAnalysis.cpp:780
     ModRefInfo Result = MRI_NoModRef;
+    ModRefInfo MustResult = MRI_Must;
 
----------------
dberlin wrote:
> hfinkel wrote:
> > Why is this useful? If we don't know which operand it is, I don't see how we use the information that it must alias one of the operands.
> So, i gave an example earlier of how must information can be useful in the llvm-dev thread that i'll copy herre. 
> It's true you don't know what operand it is, but you can ask for the location for each operand.
> Because it doesn't matter what the values are, only what they alias:
> 
> ```
> *a = something
> foo(a)
> b = *a
> ```
> 
> If foo mustalias a, not only can you possibly move foo with a, you can actually possibly clone foo here, change it to be pass-by-value, and promote the argument inside of it (if you wanted to).
> IE it's just as useful as known noalias for the memorylocation, and you have to do the same thing with the data.
> 
> If you make it 
> ```
> *a = something
> foo (a, c)
> b = *a
> ```
> 
> You can only do anything if you know they are all must-alias or no-alias anyway.
> 
> So to me, this API is as bad/good for noalias as it is for mustalias.
> 
> It costs nothing to give MRI_Must, and while we don't currrently take advantage of such info, it *is* actually useful IMHO.
> 
> 
I can certainly see this being useful if it means that all arguments must alias the given location. What's the useful thing to do here for call vs. call queries? Do we add MRI_Must only if all arguments must alias all other arguments, or is it enough if at least one argument on the LHS must alias an argument on the RHS?



================
Comment at: lib/Analysis/BasicAliasAnalysis.cpp:806
         continue;
+      if (AR == MayAlias)
+        MustResult = MRI_NoModRef;
----------------
Or PartialAlias?


https://reviews.llvm.org/D38862





More information about the llvm-commits mailing list