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

Daniel Berlin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 25 19:44:36 PDT 2017


dberlin added inline comments.


================
Comment at: lib/Analysis/AliasAnalysis.cpp:151
+    if (MR & MRI_ModRef)
+      return ModRefInfo(MRI_ModRef | (MR & MRI_Must));
   }
----------------
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.


================
Comment at: lib/Analysis/BasicAliasAnalysis.cpp:780
     ModRefInfo Result = MRI_NoModRef;
+    ModRefInfo MustResult = MRI_Must;
 
----------------
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.




https://reviews.llvm.org/D38862





More information about the llvm-commits mailing list