From: Dan Gohman Date: Fri, 2 Jul 2010 18:41:32 +0000 (+0000) Subject: Reword the definition of the noalias attribute. The intention is for X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=1e109621f1f9173df62958eca4260c809114bc3d;p=oota-llvm.git Reword the definition of the noalias attribute. The intention is for the noalias argument on function attributes be usable to model the C99 restrict keyword on arguments, and to allow AliasAnalysis to consider a noalias-attributed argument to be an "identified object". To support this, refactor a new "based on" concept out of the current pointer aliasing "associated" concept. This "based on" concept is very similar to (though it is not identical with) the "based on" concept in C99. Also, reword the definition of NoAlias to more closely describe the concept that the optimizer uses. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107495 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/AliasAnalysis.html b/docs/AliasAnalysis.html index d1f911e32dc..5e931d77a89 100644 --- a/docs/AliasAnalysis.html +++ b/docs/AliasAnalysis.html @@ -192,12 +192,14 @@ and returns MustAlias, MayAlias, or NoAlias as appropriate.
-

The NoAlias response is used when the two pointers refer to distinct objects, -regardless of whether the pointers compare equal. For example, freed pointers -don't alias any pointers that were allocated afterwards. As a degenerate case, -pointers returned by malloc(0) have no bytes for an object, and are considered -NoAlias even when malloc returns the same pointer. The same rule applies to -NULL pointers.

+

The NoAlias response may be used when there is never an immediate dependence +between any memory reference based on one pointer and any memory +reference based the other. The most obvious example is when the two +pointers point to non-overlapping memory ranges. Another is when the two +pointers are only ever used for reading memory. Another is when the memory is +freed and reallocated between accesses through one pointer and accesses through +the other -- in this case, there is a dependence, but it's mediated by the free +and reallocation.

The MayAlias response is used whenever the two pointers might refer to the same object. If the two memory objects overlap, but do not start at the same diff --git a/docs/LangRef.html b/docs/LangRef.html index 13be38fed43..2fb3d72debd 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -1051,14 +1051,13 @@ declare signext i8 @returns_signed_char() for return values.

noalias
-
This indicates that the pointer does not alias any global or any other - parameter. The caller is responsible for ensuring that this is the - case. On a function return value, noalias additionally indicates - that the pointer does not alias any other pointers visible to the - caller. For further details, please see the discussion of the NoAlias - response in - alias - analysis.
+
This indicates that pointer values + based on the argument or return + value do not alias pointer values which are not based on it. + The caller shares the responsibility with the callee for ensuring that + these requirements are met. + For further details, please see the discussion of the NoAlias response in + alias analysis.
nocapture
This indicates that the callee does not make any copies of the pointer @@ -1367,29 +1366,41 @@ is undefined. Pointer values are associated with address ranges according to the following rules:

    -
  • A pointer value formed from a - getelementptr instruction - is associated with the addresses associated with the first operand - of the getelementptr.
  • +
  • A pointer value is associated with the addresses associated with + any value it is based on.
  • An address of a global variable is associated with the address range of the variable's storage.
  • The result value of an allocation instruction is associated with the address range of the allocated storage.
  • A null pointer in the default address-space is associated with no address.
  • -
  • A pointer value formed by an - inttoptr is associated with all - address ranges of all pointer values that contribute (directly or - indirectly) to the computation of the pointer's value.
  • -
  • The result value of a - bitcast is associated with all - addresses associated with the operand of the bitcast.
  • An integer constant other than zero or a pointer value returned from a function not defined within LLVM may be associated with address ranges allocated through mechanisms other than those provided by LLVM. Such ranges shall not overlap with any ranges of addresses allocated by mechanisms provided by LLVM.
  • -
+ + +

A pointer value is based on another pointer value according + to the following rules:

+ +
    +
  • A pointer value formed from a + getelementptr operation + is based on the first operand of the getelementptr.
  • +
  • The result value of a + bitcast is based on the operand + of the bitcast.
  • +
  • A pointer value formed by an + inttoptr is based on all + pointer values that contribute (directly or indirectly) to the + computation of the pointer's value.
  • +
  • The "based on" relationship is transitive.
  • +
+ +

Note that this definition of "based" is intentionally + similar to the definition of "based" in C99, though it is + slightly weaker.

LLVM IR does not associate types with memory. The result type of a load merely indicates the size and