<div dir="ltr">Hi Neil, <div><div><br></div><div></div></div><div>The Original IR is obtained from spec2017 benchmark. I will try to reduce it to a test case and send. </div><div> The "null" value is stored to a pointer variable after calling "free" for the allocated memory. The type of the pointer is bitcasted to i8** before storing "null". <br></div><div><br></div><div>TBAA seem to represent pointer field "next" as "any pointer" in the below example.<br></div><div><br></div><div>---Snip--</div><div>struct st {<br>int a;<br>struct st * next;<br>};<br></div><div><br></div><div>struct st *ptr;</div><div>ptr->next = null</div><div> </div><div> %next = getelementptr inbounds %<a href="http://struct.st">struct.st</a>, %<a href="http://struct.st">struct.st</a>* %ptr, i64 0, i32 1<br> store %<a href="http://struct.st">struct.st</a>* null, %<a href="http://struct.st">struct.st</a>** %next, align 8, !tbaa !2<br></div><div><br></div><div>!2 = !{!3, !7, i64 8}<br></div><div><div>!3 = !{!"st", !4, i64 0, <b>!7</b>, i64 8}<br>!4 = !{!"int", !5, i64 0}<br>!5 = !{!"omnipotent char", !6, i64 0}<br>!6 = !{!"Simple C/C++ TBAA"}<br>!7 = !{!"any pointer", !5, i64 0}<br></div></div><div>--Snip--</div><div><br></div><div>TBAA will say "may alias" if it finds second store which has<b> !7</b> attached , i.e any general pointer store ?</div><div>It will not consider the context from where the second store is coming ( it may be bitcasted from a different struct * to i8**).</div><div><br></div><div>regards,</div><div>Venkat.</div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 15 Nov 2019 at 22:46, Neil Henning <<a href="mailto:neil.henning@unity3d.com" target="_blank">neil.henning@unity3d.com</a>> wrote:<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 dir="ltr">I'd need to see more of the IR if you could provide it to give a guess at the problem!</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Nov 15, 2019 at 4:49 PM Venkataramanan Kumar <<a href="mailto:venkataramanan.kumar.llvm@gmail.com" target="_blank">venkataramanan.kumar.llvm@gmail.com</a>> wrote:<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 dir="ltr"><div>Hi Neil</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 15 Nov 2019 at 15:26, Neil Henning <<a href="mailto:neil.henning@unity3d.com" target="_blank">neil.henning@unity3d.com</a>> wrote:<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 dir="ltr"><div>What are you querying the alias analysis on in the above example - between the load and store?</div></div></blockquote><div><br></div><div>I am interested to check if the load "%2" is not changed inside the function (assuming there are no function calls). I am checking to see if there are any store instructions in that function that could aliases and </div><div>modify the load.</div><div><br></div><div><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 dir="ltr"><div><br></div><div>How are you creating your MemoryLocation for those too?<br></div></div></blockquote><div><br></div><div>I query using alias method as shown below. </div><div><br></div><div>MemoryLocation Locld = MemoryLocation::get(Loadinst);<br>MemoryLocation Locst = MemoryLocation::get(Storeinst);<br><br>if (AA->alias(Loc,Locst) != llvm::NoAlias ) {<br> ==> it reaches here <br>}<br><br>Also checked modref info.<br>if(isModSet(AA->getModRefInfo(Storeinst, Loc))<br>{<br> ==> it reaches here<br></div><div>}</div><div><br></div><div>regards,</div><div>Venkat, </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Nov 15, 2019 at 6:03 AM Venkataramanan Kumar via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<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 dir="ltr"><div dir="ltr">Can someone please clarify me on this?<br><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 13 Nov 2019 at 22:25, Venkataramanan Kumar <<a href="mailto:venkataramanan.kumar.llvm@gmail.com" target="_blank">venkataramanan.kumar.llvm@gmail.com</a>> wrote:<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 dir="ltr"><div>Hi, </div><div><br></div>I have the following LLVM IR.<br><br>----Snip---<br>%1 = getelementptr inbounds %struct._X, %struct._X* %0, i64 0, i32 3<br>%2 = load %struct._X*, %struct._X** %1, align 8, !tbaa !10<br>....<div>.....<br>.......<br><br>%3 = bitcast %struct._Y** %1 to i8**<br>store i8* null, i8** %3, align 8, !tbaa !9<br><br>!9 = !{!7, !7, i64 0}<br>!7 = !{!"omnipotent char", !8, i64 0}<br>!8 = !{!"Simple C/C++ TBAA"}<br><br>----Snip----<br><br>Load inst above is trying to access a field of _X which is a self recursive pointer to same struct _X.<br>Store puts a null value for a pointer to struct _Y. It has been bitcasted to i8** and store happens via char pointer. <br><br><br>When I query alias analysis although loads and stores are pointers to different struct types. TBAA says may alias.<br>is it safe to assume the loaded pointer to struct _X do not alias with the store , if we look further at bitcast and see the pointer to different struct? <br></div><div><br></div><div>is my understanding wrong here?</div><div><br></div><div>regards,</div><div>Venkat,</div></div>
</blockquote></div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr"><div dir="ltr"><table style="border-collapse:collapse;border-spacing:0px;color:rgb(90,90,91);font-size:13px;margin:0px 0px 20px;padding:0px" width="100%" cellspacing="0" cellpadding="0" border="0"><tbody style="margin:0px;padding:0px"><tr style="margin:0px;padding:0px"><td style="border-collapse:collapse;font-size:0px;line-height:1.5em;padding:0px 0px 20px;vertical-align:top" align="left"><table style="border-collapse:collapse;border-spacing:0px;margin:0px;padding:0px" cellspacing="0" cellpadding="0" border="0" align="left"><tbody style="margin:0px;padding:0px"><tr style="margin:0px;padding:0px"><td style="border-collapse:collapse;font-size:1.12em;line-height:1.5em;padding:0px;vertical-align:top;width:64px"><img style="border: medium none; border-radius: 0px; display: block; font-size: 13px; height: auto; line-height: 100%; margin: 0px; max-width: 100%; outline-style: none; outline-width: medium; padding: 20px 0px 0px; width: 100%;" alt="" src="https://unity3d.com/profiles/unity3d/themes/unity/images/ui/other/unity-logo-dark-email.png" width="64" height="auto"></td></tr></tbody></table></td></tr><tr style="margin:0px;padding:0px"><td style="border-collapse:collapse;font-size:0px;line-height:1.5em;padding:0px;vertical-align:top" align="left"><div style="color:rgb(0,0,0);font-family:Roboto,Arial;font-size:14px;font-weight:600;line-height:15px;margin:0px;padding:0px">Neil Henning</div></td></tr><tr style="margin:0px;padding:0px"><td style="border-collapse:collapse;font-size:0px;line-height:1.5em;padding:0px;vertical-align:top" align="left"><div style="color:rgb(0,0,0);font-family:Roboto,Arial;font-size:14px;line-height:15px;margin:0px;padding:0px 0px 10px">Senior Software Engineer Compiler</div></td></tr><tr style="margin:0px;padding:0px"><td style="border-collapse:collapse;font-size:0px;line-height:1.5em;padding:0px;vertical-align:top" align="left"><div style="color:rgb(0,0,0);font-family:Roboto,Arial;font-size:12px;line-height:15px;margin:0px;padding:0px"><a href="http://unity.com" target="_blank">unity.com</a></div></td></tr></tbody></table></div></div>
</blockquote></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-collapse:collapse;border-spacing:0px;color:rgb(90,90,91);font-size:13px;margin:0px 0px 20px;padding:0px"><tbody style="margin:0px;padding:0px"><tr style="margin:0px;padding:0px"><td align="left" style="border-collapse:collapse;font-size:0px;line-height:1.5em;padding:0px 0px 20px;vertical-align:top"><table align="left" style="border-collapse:collapse;border-spacing:0px;margin:0px;padding:0px" border="0" cellspacing="0" cellpadding="0"><tbody style="margin:0px;padding:0px"><tr style="margin:0px;padding:0px"><td style="border-collapse:collapse;font-size:1.12em;line-height:1.5em;padding:0px;vertical-align:top;width:64px"><img width="64" height="auto" style="border: medium none currentcolor; border-radius: 0px; display: block; font-size: 13px; height: auto; line-height: 100%; margin: 0px; max-width: 100%; outline-style: none; outline-width: medium; padding: 20px 0px 0px; width: 100%;" alt="" src="https://unity3d.com/profiles/unity3d/themes/unity/images/ui/other/unity-logo-dark-email.png"></td></tr></tbody></table></td></tr><tr style="margin:0px;padding:0px"><td align="left" style="border-collapse:collapse;font-size:0px;line-height:1.5em;padding:0px;vertical-align:top"><div style="color:rgb(0,0,0);font-family:Roboto,Arial;font-size:14px;font-weight:600;line-height:15px;margin:0px;padding:0px">Neil Henning</div></td></tr><tr style="margin:0px;padding:0px"><td align="left" style="border-collapse:collapse;font-size:0px;line-height:1.5em;padding:0px;vertical-align:top"><div style="color:rgb(0,0,0);font-family:Roboto,Arial;font-size:14px;line-height:15px;margin:0px;padding:0px 0px 10px">Senior Software Engineer Compiler</div></td></tr><tr style="margin:0px;padding:0px"><td align="left" style="border-collapse:collapse;font-size:0px;line-height:1.5em;padding:0px;vertical-align:top"><div style="color:rgb(0,0,0);font-family:Roboto,Arial;font-size:12px;line-height:15px;margin:0px;padding:0px"><a href="http://unity.com" target="_blank">unity.com</a></div></td></tr></tbody></table></div></div>
</blockquote></div>