I'm attaching the .bc file. Note that my analysis pass is invoked after "-O1" and that's why the IR I included in the original email is optimized. -------------- next part -------------- A non-text attachment was scrubbed... Name: simple_loops_F2_4list.bc Type: application/octet-stream Size: 6384 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090413/779e1ae8/attachment.obj> -------------- next part -------------- On Apr 13, 2009, at 2:21 PM, Chris Lattner wrote:> On Apr 13, 2009, at 9:06 AM, Anthony Danalis wrote: >> Hello, >> >> I have a code similar to the following: > > Hi Anthony, > > Can you please attach the .bc file for this? > > -Chris > >> >> >> 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) >> enddo >> >> 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) >> and >> N = N+7 (store i32 %12, i32* %n, align 4) >> are the ones that define the parameters "j" and "N" respectively? >> >> thanks, >> Anthony >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
On Apr 13, 2009, at 12:01 PM, Anthony Danalis wrote:> I'm attaching the .bc file. Note that my analysis pass is invoked > after "-O1" and that's why the IR I included in the original email > is optimized.Hi Anthony, Sorry for the delay, things have been crazy lately. The MemDep API assumes that you will call getDependency() first, and then only call getNonLocalPointerDependency() if it returns non- local. This will return the first instruction that the instruction is dependent on. As Eli mentioned, MemDep does have some more rich APIs that are private. We could look the export those so that you can query each argument at a time. The problem is that (without more information about language semantics) there is no way to know how much data is accessed off each pointer by the function, nor whether it accesses them through other aliases. For example, "bar" could capture the N pointer, etc. -Chris> > <simple_loops_F2_4list.bc> > On Apr 13, 2009, at 2:21 PM, Chris Lattner wrote: > >> On Apr 13, 2009, at 9:06 AM, Anthony Danalis wrote: >>> Hello, >>> >>> I have a code similar to the following: >> >> Hi Anthony, >> >> Can you please attach the .bc file for this? >> >> -Chris >> >>> >>> >>> 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) >>> enddo >>> >>> 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) >>> and >>> N = N+7 (store i32 %12, i32* %n, align 4) >>> are the ones that define the parameters "j" and "N" respectively? >>> >>> thanks, >>> Anthony >>> _______________________________________________ >>> LLVM Developers mailing list >>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
On Apr 25, 2009, at 5:05 PM, Chris Lattner wrote:> > On Apr 13, 2009, at 12:01 PM, Anthony Danalis wrote: > >> I'm attaching the .bc file. Note that my analysis pass is invoked >> after "-O1" and that's why the IR I included in the original email >> is optimized. > > Hi Anthony, > > Sorry for the delay, things have been crazy lately. > > The MemDep API assumes that you will call getDependency() first, and > then only call getNonLocalPointerDependency() if it returns non- > local. This will return the first instruction that the instruction is > dependent on. > > As Eli mentioned, MemDep does have some more rich APIs that are > private. We could look the export those so that you can query each > argument at a time.Actually there is no need to export it. I wrote a little ReachingDefinitions pass based on the API from MemDep that gives me the information I want. I should probably send it in, but I'm not sure how to do so. Should I submit it as a patch to the list, or try to commit it in the svn?> The problem is that (without more information > about language semantics) there is no way to know how much data is > accessed off each pointer by the function, nor whether it accesses > them through other aliases. For example, "bar" could capture the N > pointer, etc. > > -Chris > > >> >> <simple_loops_F2_4list.bc> >> On Apr 13, 2009, at 2:21 PM, Chris Lattner wrote: >> >>> On Apr 13, 2009, at 9:06 AM, Anthony Danalis wrote: >>>> Hello, >>>> >>>> I have a code similar to the following: >>> >>> Hi Anthony, >>> >>> Can you please attach the .bc file for this? >>> >>> -Chris >>> >>>> >>>> >>>> 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) >>>> enddo >>>> >>>> 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) >>>> and >>>> N = N+7 (store i32 %12, i32* %n, align 4) >>>> are the ones that define the parameters "j" and "N" respectively? >>>> >>>> thanks, >>>> Anthony >>>> _______________________________________________ >>>> LLVM Developers mailing list >>>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >>> >>> _______________________________________________ >>> LLVM Developers mailing list >>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev