<div dir="ltr"><div>Dear Hal,</div><div>Thanks for your reply.</div><div>I was initially not giving the LocationSize, which seems to have been the problem.</div><div>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!</div><div>(Although I will have to check more if this is doing a correct thing in general)</div><div><br></div><div>e.g., for future reference,</div><div>I have 'a' which is the argument of a load/store and 'b' which is the global array. I am doing</div><div><br></div><div>const auto &DL = m->getDataLayout();<br>LocationSize LS0 = LocationSize::precise(<br> DL.getTypeStoreSize(a->getType()));<br>LocationSize LS1 = LocationSize::precise(<br> DL.getTypeStoreSize(b->getType())
*ARRAY_SIZE
);<br>AA->alias(a, LS0, b, LS1);</div><div><br></div><div>Thank you for your help,</div><div>Best Regards,</div><div>Kiwan<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">2019년 11월 9일 (토) 오전 4:40, Finkel, Hal J. <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>>님이 작성:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">
<p>Hi, Kiwan,</p>
<p>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.</p>
<p> -Hal<br>
</p>
<div>On 11/5/19 6:05 PM, 맹기완 via llvm-dev wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>I have a global 2-D array ARRAY[N][M] and I am accessing it inside the for loop like this:</div>
<div><br>
</div>
<div>for (i...)</div>
<div> for (j ...)</div>
<div> ARRAY[i][j] ...</div>
<div><br>
</div>
<div>So nothing really weird is happening. If I look at the generated IR, it is also fairly straight forward.</div>
<div><br>
</div>
<div>@ARRAY0 = dso_local global [32 x [32 x i32]] zeroinitializer, section ".slow_mem", align 32, !dbg !84<br>
...<br>
%45 = getelementptr inbounds [32 x [32 x i32]], [32 x [32 x i32]]* @ARRAY0, i32 0, i32 %22, i32 7, !dbg !180<br>
store volatile i32 %43, i32* %45, align 4, !dbg !181, !tbaa !148</div>
<div><br>
</div>
<div>As you can see, the GEPInst exactly knows it is the ARRAY0, and it knows statically that it is accessing the 7th element.</div>
<div>However, when I try to call alias analysis in the LLVM pass, as in</div>
<div><br>
</div>
<div>AliasAnalysis *AA = ...<br>
</div>
<div>AA->alias(a, b)<br>
</div>
<div><br>
</div>
<div>where a is the ARRAY0 global variable and b is the GEPInst (%45), I only get mayAlias.</div>
<div>When reading the basicaa description, it seems like it should know that the two is must alias. What am I missing?</div>
<div><br>
</div>
<div>I did not know how I should post code in the thread, so I apologize for the messy format.<br>
</div>
<div>Thank you,</div>
<div>Best Regards,</div>
<div>Kiwan<br>
</div>
</div>
<br>
<fieldset></fieldset>
<pre>_______________________________________________
LLVM Developers mailing list
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<pre cols="72">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</div>
</blockquote></div>