diff --git a/docs/AliasAnalysis.html b/docs/AliasAnalysis.html index 10227fb90a5..d137ffe5f39 100644 --- a/docs/AliasAnalysis.html +++ b/docs/AliasAnalysis.html @@ -134,16 +134,18 @@ symbolic LLVM Value*) and a static size.

important for correct Alias Analyses. For example, consider this (silly, but possible) C code:

+
-  int i;
-  char C[2];
-  char A[10]; 
-  /* ... */
-  for (i = 0; i != 10; ++i) {
-    C[0] = A[i];          /* One byte store */
-    C[1] = A[9-i];        /* One byte store */
-  }
+int i;
+char C[2];
+char A[10]; 
+/* ... */
+for (i = 0; i != 10; ++i) {
+  C[0] = A[i];          /* One byte store */
+  C[1] = A[9-i];        /* One byte store */
+}
 
+

In this case, the basicaa pass will disambiguate the stores to C[0] and C[1] because they are accesses to two distinct @@ -151,16 +153,18 @@ locations one byte apart, and the accesses are each one byte. In this case, the LICM pass can use store motion to remove the stores from the loop. In constrast, the following code:

+
-  int i;
-  char C[2];
-  char A[10]; 
-  /* ... */
-  for (i = 0; i != 10; ++i) {
-    ((short*)C)[0] = A[i];  /* Two byte store! */
-    C[1] = A[9-i];          /* One byte store */
-  }
+int i;
+char C[2];
+char A[10]; 
+/* ... */
+for (i = 0; i != 10; ++i) {
+  ((short*)C)[0] = A[i];  /* Two byte store! */
+  C[1] = A[9-i];          /* One byte store */
+}
 
+

In this case, the two stores to C do alias each other, because the access to the &C[0] element is a two byte access. If size information wasn't @@ -361,25 +365,29 @@ the AliasAnalysis base class: getAnalysisUsage and declaring any pass dependencies your pass has. Thus you should have something like this:

+
-    void getAnalysisUsage(AnalysisUsage &AU) const {
-      AliasAnalysis::getAnalysisUsage(AU);
-      // declare your dependencies here.
-    }
+void getAnalysisUsage(AnalysisUsage &AU) const {
+  AliasAnalysis::getAnalysisUsage(AU);
+  // declare your dependencies here.
+}
 
+

Additionally, your must invoke the InitializeAliasAnalysis method from your analysis run method (run for a Pass, runOnFunction for a FunctionPass, or InitializePass for an ImmutablePass). For example (as part of a Pass):

+
-    bool run(Module &M) {
-      InitializeAliasAnalysis(this);
-      // Perform analysis here...
-      return false;
-    }
+bool run(Module &M) {
+  InitializeAliasAnalysis(this);
+  // Perform analysis here...
+  return false;
+}
 
+
@@ -419,17 +427,19 @@ for methods that you don't override. For methods that you do override, in code paths that return a conservative MayAlias or Mod/Ref result, simply return whatever the superclass computes. For example:

+
-  AliasAnalysis::AliasResult alias(const Value *V1, unsigned V1Size,
-                                   const Value *V2, unsigned V2Size) {
-    if (...)
-      return NoAlias;
-    ...
+AliasAnalysis::AliasResult alias(const Value *V1, unsigned V1Size,
+                                 const Value *V2, unsigned V2Size) {
+  if (...)
+    return NoAlias;
+  ...
 
-    // Couldn't determine a must or no-alias result.
-    return AliasAnalysis::alias(V1, V1Size, V2, V2Size);
-  }
+  // Couldn't determine a must or no-alias result.
+  return AliasAnalysis::alias(V1, V1Size, V2, V2Size);
+}
 
+

In addition to analysis queries, you must make sure to unconditionally pass LLVM update notification methods to the superclass as @@ -473,7 +483,6 @@ for each value in the program. When this method is called, they should remove any entries for the specified value, if they exist. -

The copyValue method
@@ -485,7 +494,6 @@ this is the only way to introduce a new value. This method indicates that the new value has exactly the same properties as the value being copied. -
The replaceWithNewValue method
@@ -549,8 +557,8 @@ just use the load-vn pass, which uses alias analysis.

Many transformations need information about alias sets that are active in some scope, rather than information about pairwise aliasing. The AliasSetTracker class is used -to efficiently build these Alias Sets from the pairwise alias analysis +href="/doxygen/classllvm_1_1AliasSetTracker.html">AliasSetTracker class +is used to efficiently build these Alias Sets from the pairwise alias analysis information provided by the AliasAnalysis interface.

First you initialize the AliasSetTracker by using the "add" methods @@ -602,7 +610,6 @@ are.

-
Using the AliasAnalysis interface directly @@ -662,7 +669,6 @@ problem.

-
The -basicaa pass @@ -845,8 +851,8 @@ pointer.

-

-The -load-vn pass uses alias analysis to "value + +

The -load-vn pass uses alias analysis to "value number" loads and pointers values, which is used by the GCSE pass to eliminate instructions. The -load-vn pass relies on alias information and must-alias information. This combination of passes can make the following @@ -864,18 +870,19 @@ calls into direct calls.

- - -
- Clients for debugging and evaluation of implementations + Clients for debugging and evaluation of + implementations
-These passes are useful for evaluating the various alias analysis -implementations. You can use them with commands like 'opt -anders-aa -ds-aa --aa-eval foo.bc -disable-output -stats'. +
+

These passes are useful for evaluating the various alias analysis +implementations. You can use them with commands like 'opt -anders-aa -ds-aa +-aa-eval foo.bc -disable-output -stats'.

+ +
@@ -900,17 +907,19 @@ the AliasSetTracker class.

The -count-aa pass is useful to see how many queries a particular -pass is making and what responses are returned by the alias analysis. An -example usage is:

+pass is making and what responses are returned by the alias analysis. As an +example,

+
-  $ opt -basicaa -count-aa -ds-aa -count-aa -licm
+% opt -basicaa -count-aa -ds-aa -count-aa -licm
 
+
-

Which will print out how many queries (and what responses are returned) by -the -licm pass (of the -ds-aa pass) and how many queries are -made of the -basicaa pass by the -ds-aa pass. This can be -useful when debugging a transformation or an alias analysis implementation.

+

will print out how many queries (and what responses are returned) by the +-licm pass (of the -ds-aa pass) and how many queries are made +of the -basicaa pass by the -ds-aa pass. This can be useful +when debugging a transformation or an alias analysis implementation.