[LLVMdev] Alias Analysis across functions

Madhusudan, Vinay Vinay.Madhusudan at amd.com
Mon Sep 29 23:06:56 PDT 2014


Hi Hal,



I could not get the better result from the new “cfl-aa” as well. But  "cfl-aa" seems to be less accurate than "basicaa" for the following basic example! Am I missing something?



Example:



int func () {

  int A[100], B[100];

  int i = 0, sum1 =0;



  for (; i < 100; ++i) {

   A[i] = B[i] = i;

  }

  for (i = 0; i < 100; ++i) {

    sum1 += A[i] +  B[i];

  }



  return sum1;

}



Output of “opt -mem2reg -basicaa –print-alias-sets”:



Alias Set Tracker: 2 alias sets for 4 pointer values.

  AliasSet[0x3b01890, 2] may alias, Mod/Ref   Pointers: (i32* %A.arrayidx, 4), (i32* %A.arrayidx9, 4)

  AliasSet[0x3b012a0, 2] may alias, Mod/Ref   Pointers: (i32* %B.arrayidx2, 4), (i32* %B.arrayidx7, 4)





Output of “opt -mem2reg –cfl-aa –print-alias-sets” and “opt –mem2reg –basicaa –cfl-aa –print-alias-sets”:



Alias Set Tracker: 1 alias sets for 4 pointer values.

  AliasSet[0x3046890, 4] may alias, Mod/Ref   Pointers: (i32* %A.arrayidx, 4), (i32* %B.arrayidx2, 4), (i32* %B.arrayidx7, 4), (i32* %A.arrayidx9, 4)



Thanks,

Vinay



-----Original Message-----
From: Hal Finkel [mailto:hfinkel at anl.gov]
Sent: Monday, September 29, 2014 6:22 PM
To: Madhusudan, Vinay
Cc: LLVM Developers Mailing List (llvmdev at cs.uiuc.edu)
Subject: Re: [LLVMdev] Alias Analysis across functions



Hi Vinay,



The new -cfl-aa has an IPA that might catch this. Also, I'm working on a new pass to do top-down function parameter attribute propagation, which should catch this (http://reviews.llvm.org/D4609), but it is not quite ready yet.



-Hal



----- Original Message -----

> From: "Vinay Madhusudan" <Vinay.Madhusudan at amd.com<mailto:Vinay.Madhusudan at amd.com>>

> To: "LLVM Developers Mailing List (llvmdev at cs.uiuc.edu<mailto:llvmdev at cs.uiuc.edu>)"

> <llvmdev at cs.uiuc.edu<mailto:llvmdev at cs.uiuc.edu>>

> Sent: Monday, September 29, 2014 12:55:18 AM

> Subject: [LLVMdev] Alias Analysis across functions

>

>

>

> 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

>

> _______________________________________________

> LLVM Developers mailing list

> LLVMdev at cs.uiuc.edu<mailto:LLVMdev at cs.uiuc.edu>         http://llvm.cs.uiuc.edu

> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

>



--

Hal Finkel

Assistant Computational Scientist

Leadership Computing Facility

Argonne National Laboratory
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140930/8e8acef6/attachment.html>


More information about the llvm-dev mailing list