[LLVMdev] MemoryDependenceAnalysis

Anthony Danalis adanalis at eecs.utk.edu
Mon Apr 13 09:06:02 PDT 2009


I have a code similar to the following:

         program test
             integer i, j, N
             real B(10)

             call bar(N, 8)
             N = N+1
             do i = 1, N
                 B(i) = (i+5)/(i+3)

             j = N/2
             N = N+7

             call IMPORTANT_F(B, N, i, j)

         end program

and I am trying to use dependence analysis on the second and fourth  
actual parameters of IMPORTANT_F().  Since it's Fortran, they are  
really pointers, and the IR of the last block looks like this:

         %11 = sdiv i32 %1, 2            ; <i32> [#uses=1]
         store i32 %11, i32* %j, align 4
         %12 = add i32 %0, 8             ; <i32> [#uses=1]
         store i32 %12, i32* %n, align 4
         call void (...)* @IMPORTANT_F_([10 x float]* %b, i32* %n,  
i32* %i, i32* %j) nounwind
         ret void

My problem is that if I use getNonLocalPointerDependency() I get the  
instruction "N=N+1" as a Def for the second parameter, "N",  and no  
Def for the fourth, "j", (only the call to "bar()" as clobber).
If I use getDependency() on the call, I get the instruction "N=N+7" as  
a clobber.

How can I use MemoryDependenceAnalysis (or any other analysis for that  
matter) to gather that the instructions
j = N/2  (store i32 %11, i32* %j, align 4)
N = N+7  (store i32 %12, i32* %n, align 4)
are the ones that define the parameters "j" and "N" respectively?


More information about the llvm-dev mailing list