[llvm-dev] A bug in DependenceAnalysis?

Stanislav Manilov via llvm-dev llvm-dev at lists.llvm.org
Wed Jun 21 09:58:17 PDT 2017


Hi Philip,

Thanks for checking!

I'm running my own Foo pass that registers DependenceAnalysisWrapperPass as
a prerequisite and then I run it like so:

opt -load libfoo.so -foo example.bc

This is LLVM 3.9.

Cheers,
 - Stan

On Wed, Jun 21, 2017 at 5:40 PM, Philip Pfaffe <philip.pfaffe at gmail.com>
wrote:

> Hi Stan,
>
> in both cases I get a consistent anti result. Can you show us the command
> lines you're using? Which version of llvm is this?
>
> Best,
> Philip
>
> 2017-06-21 17:56 GMT+02:00 Stanislav Manilov via llvm-dev <
> llvm-dev at lists.llvm.org>:
>
>> Hello llvm-dev,
>>
>> I'm running a pass that uses the result of llvm::DependenceAnalysisWrapperPass
>> to compute the dependencies between all instructions of a loop. I have the
>> following two examples of code I wish to analyse:
>>
>> example A:
>>
>> ```
>> void move_one(int *A, unsigned n) {
>>   for (unsigned i = 0; i < n-1; ++i) {
>>     A[i] = A[i + 1];
>>   }
>> }
>> ```
>> and example B:
>> ```
>> void move_one_alt(int *A, unsigned n) {
>>   int *B = A + 1;
>>   for (unsigned i = 0; i < n-1; ++i) {
>>     A[i] = B[i];
>>   }
>> }
>> ```
>>
>> I would expect that I get the same result for both A and B, namely a loop
>> carried anti (WAR) dependence from the generated load instruction to the
>> generated store instruction. This should be the case, because on iteration
>> i+1 the loop is writing to the element that has been read in the previous
>> iteration - iteration i.
>>
>> However, in example A I get a loop carried flow (RAW) dependence from the
>> store instruction to the load instruction, while in example B I don't get
>> any dependence at all.
>>
>> Am I missing something, or is the result wrong?
>>
>> Thanks,
>>  - Stan
>>
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170621/73b46729/attachment.html>


More information about the llvm-dev mailing list