[PATCH] D28394: [AliasAnalysis] Limit `MemoryLocation` retrieval to valid intrinsic arguments.

bryant via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 6 19:32:23 PST 2017


bryant added inline comments.


================
Comment at: lib/Analysis/AliasAnalysis.cpp:177
+        unsigned ArgIdx = A.Index;
+        if (!Arg->getType()->isPointerTy() || CS.doesNotAccessMemory(ArgIdx))
           continue;
----------------
reames wrote:
> I'm missing something here.  *Why* is it problematic to ask for a memory location of the parameter to invariant_end?  I would expect that to just work.  
Here are the type sigs for the invariant intrinsics:

    declare {}* @llvm.invariant.start.p0i8(i64 <size>, i8* nocapture <ptr>)
    declare void @llvm.invariant.end.p0i8({}* readnone <start>, i64 <size>, i8* nocapture <ptr>)

And the semantics for invariant.start:

> This intrinsic indicates that until an ``llvm.invariant.end`` that uses the return value, the referenced memory location is constant and unchanging.

So if I were to venture a guess, the {}* opaque return is meant to be used as a token, not a real memory address. Only the <ptr> parameter of both is a legit pointer, so getForArgument is likewise restricted to that.

(As an aside: Why not have invariant.start return a real pointer to <ptr> with the desired memory semantics?)

I am definitely not an expert on this and defer to Hal for a real explanation.


Repository:
  rL LLVM

https://reviews.llvm.org/D28394





More information about the llvm-commits mailing list