[LLVMdev] Alias Analysis across functions

Madhusudan, Vinay Vinay.Madhusudan at amd.com
Sun Sep 28 22:55:18 PDT 2014


Hi,

I am trying to get the alias info for the following code. The alias analysis returns "MayAlias" for arrays "A" and "B" in both the functions instead of "NoAlias". What passes should I run in opt before the alias analysis pass to get the accurate result?

Example:

//Note: static and called by func() only.
static int sum(int *A, int *B) {

  int i = 0, sum1 = 0;

  for (i = 0; i < 100; ++i) {
    sum1 += A[i] +  B[i];
  }
  return sum1;
}

int func () {
  int A[100], B[100];
  int i = 0;
  for (; i < 100; ++i) {
   A[i] = B[i] = i;
  }
  return sum(A,B);
}

Arguments to opt: "-mem2reg  -basicaa -scev-aa  -print-alias-sets"

Output:
Function: func
Alias Set Tracker: 2 alias sets for 2 pointer values.
  AliasSet[0x2bc88b0, 2] may alias, Mod/Ref   Pointers: (i32* %A.arrayidx, 4), (i32* %B.arrayidx2, 4)
    1 Unknown instructions: i32 %call
  AliasSet[0x2bc8490, 1] must alias, Mod        forwarding to 0x2bc88b0

Function: sum
Alias Set Tracker: 1 alias sets for 2 pointer values.
  AliasSet[0x2bcbb50, 2] may alias, Ref       Pointers: (i32* %A.arrayidx, 4), (i32* %B.arrayidx2, 4)


Thanks,
Vinay

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140929/c6d06af1/attachment.html>


More information about the llvm-dev mailing list