[LLVMdev] Alias Analysis across functions

Hal Finkel hfinkel at anl.gov
Mon Sep 29 23:11:40 PDT 2014


----- Original Message -----
> From: "Vinay Madhusudan" <Vinay.Madhusudan at amd.com>
> To: "Hal Finkel" <hfinkel at anl.gov>
> Cc: "LLVM Developers Mailing List (llvmdev at cs.uiuc.edu)" <llvmdev at cs.uiuc.edu>
> Sent: Tuesday, September 30, 2014 1:06:56 AM
> Subject: RE: [LLVMdev] Alias Analysis across functions
> 
> 
> 
> 
> 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?
> 

cfl-aa is intended to be used as a supplement to, not a replacement for, basicaa. Use -cfl-aa -basicaa (the order is significant; this will query basicaa first).

 -Hal

> 
> 
> 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 >
> 
> > To: "LLVM Developers Mailing List ( llvmdev at cs.uiuc.edu )"
> 
> > < 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 http://llvm.cs.uiuc.edu
> 
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> 
> > 
> 
> 
> 
> --
> 
> Hal Finkel
> 
> Assistant Computational Scientist
> 
> Leadership Computing Facility
> 
> Argonne National Laboratory

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory




More information about the llvm-dev mailing list