[llvm-dev] Alias analysis only throwing mayAlias for something that seems should be identifiable as mustAlias

맹기완 via llvm-dev llvm-dev at lists.llvm.org
Sat Nov 9 13:14:10 PST 2019


Dear Hal,
Thanks for your reply.
I was initially not giving the LocationSize, which seems to have been the
problem.
I tried giving the size of the load/store for the first argument and size
of the entire array for the second argument and it is now giving MustAlias!
(Although I will have to check more if this is doing a correct thing in
general)

e.g., for future reference,
I have 'a' which is the argument of a load/store and 'b' which is the
global array. I am doing

const auto &DL = m->getDataLayout();
LocationSize LS0 = LocationSize::precise(
                                        DL.getTypeStoreSize(a->getType()));
LocationSize LS1 = LocationSize::precise(
                                        DL.getTypeStoreSize(b->getType())
*ARRAY_SIZE );
AA->alias(a, LS0, b, LS1);

Thank you for your help,
Best Regards,
Kiwan

2019년 11월 9일 (토) 오전 4:40, Finkel, Hal J. <hfinkel at anl.gov>님이 작성:

> Hi, Kiwan,
>
> What sizes are you passing to AA when you make the query (i.e., how are
> you constructing the MemoryLocation)? I would expect an access to the
> eighth element and the first element to be NoAlias, although maybe MayAlias
> if something is confusing the analysis.
>
>  -Hal
> On 11/5/19 6:05 PM, 맹기완 via llvm-dev wrote:
>
> I have a global 2-D array ARRAY[N][M] and I am accessing it inside the for
> loop like this:
>
> for (i...)
>   for (j ...)
>     ARRAY[i][j] ...
>
> So nothing really weird is happening. If I look at the generated IR, it is
> also fairly straight forward.
>
> @ARRAY0 = dso_local global [32 x [32 x i32]] zeroinitializer, section
> ".slow_mem", align 32, !dbg !84
> ...
> %45 = getelementptr inbounds [32 x [32 x i32]], [32 x [32 x i32]]*
> @ARRAY0, i32 0, i32 %22, i32 7, !dbg !180
> store volatile i32 %43, i32* %45, align 4, !dbg !181, !tbaa !148
>
> As you can see, the GEPInst exactly knows it is the ARRAY0, and it knows
> statically that it is accessing the 7th element.
> However, when I try to call alias analysis in the LLVM pass, as in
>
> AliasAnalysis *AA = ...
> AA->alias(a, b)
>
> where a is the ARRAY0 global variable and b is the GEPInst (%45), I only
> get mayAlias.
> When reading the basicaa description, it seems like it should know that
> the two is must alias. What am I missing?
>
> I did not know how I should post code in the thread, so I apologize for
> the messy format.
> Thank you,
> Best Regards,
> Kiwan
>
> _______________________________________________
> LLVM Developers mailing listllvm-dev at lists.llvm.orghttps://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
> --
> Hal Finkel
> Lead, Compiler Technology and Programming Languages
> Leadership Computing Facility
> Argonne National Laboratory
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191109/39b5805e/attachment.html>


More information about the llvm-dev mailing list