<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Hi Neil,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This should be solved with the 'full restrict patches' <a href="https://reviews.llvm.org/D68484">
https://reviews.llvm.org/D68484</a> : it treats %noalias arguments in a different<o:p></o:p></p>
<p class="MsoNormal">way so that we keep more accurate information during SROA.<o:p></o:p></p>
<p class="MsoNormal">A convenience single patch is available here: <a href="https://reviews.llvm.org/D69542">
https://reviews.llvm.org/D69542</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Please let me know, if you happen to try it out, that it indeed solves your problem.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Jeroen Dobbelaere<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> llvm-dev <llvm-dev-bounces@lists.llvm.org> <b>On Behalf Of
</b>Neil Henning via llvm-dev<br>
<b>Sent:</b> Friday, January 17, 2020 17:22<br>
<b>To:</b> llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Subject:</b> [llvm-dev] Help with SROA throwing away no-alias information<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">I'm having an issue where SROA will throw away no-alias information on some loads after inlining, because the loads are derived from a store to an alloca which can be removed after inlining.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">The pointers that were originally stored into the alloca do <b>
not </b>have any aliasing information - the only context that allowed me to assert aliasing was that the inlined-function guaranteed it to be so.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I know why SROA has done this - its just removing a store -> load on an alloca by forwarding the store, but is there anyway I can preserve the information that these pointers must no-alias?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Here is the pre/post from when SROA is run and you can see the now missing information of no-alias:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">define dllexport void @"Burst.Compiler.IL.Tests.Aliasing.CheckInlinedFunctionPreservesAliasing(ref Burst.Compiler.IL.Tests.Aliasing.NoAliasWithContentsStruct s)_862A52BC559AC318"(%"Burst.Compiler.IL.Tests.Aliasing/NoAliasWithContentsStruct"*
 nocapture nonnull readonly %s) local_unnamed_addr #0 !ubaa. !1 {<br>
entry:<br>
  %var.0 = alloca %"Burst.Compiler.IL.Tests.Aliasing/NoAliasField", align 8<br>
  %0 = bitcast %"Burst.Compiler.IL.Tests.Aliasing/NoAliasWithContentsStruct"* %s to i64*<br>
  %1 = load i64, i64* %0, align 1<br>
  %2 = getelementptr %"Burst.Compiler.IL.Tests.Aliasing/NoAliasWithContentsStruct", %"Burst.Compiler.IL.Tests.Aliasing/NoAliasWithContentsStruct"* %s, i64 0, i32 1<br>
  %3 = bitcast i8** %2 to i64*<br>
  %4 = load i64, i64* %3, align 1<br>
  %5 = bitcast %"Burst.Compiler.IL.Tests.Aliasing/NoAliasField"* %var.0 to i64*<br>
  store i64 %1, i64* %5, align 8<br>
  %.fca.1.gep = getelementptr inbounds %"Burst.Compiler.IL.Tests.Aliasing/NoAliasField", %"Burst.Compiler.IL.Tests.Aliasing/NoAliasField"* %var.0, i64 0, i32 1<br>
  %6 = bitcast i32** %.fca.1.gep to i64*<br>
  store i64 %4, i64* %6, align 8<br>
  %7 = bitcast %"Burst.Compiler.IL.Tests.Aliasing/NoAliasField"* %var.0 to i8**<br>
  %8 = load i8*, i8** %7, align 1, !alias.scope !2, !noalias !5<br>
  %9 = getelementptr %"Burst.Compiler.IL.Tests.Aliasing/NoAliasField", %"Burst.Compiler.IL.Tests.Aliasing/NoAliasField"* %var.0, i64 0, i32 1<br>
  %10 = bitcast i32** %9 to i8**<br>
  %11 = load i8*, i8** %10, align 1, !alias.scope !5, !noalias !2<br>
  call void @llvm.ubaa.expect.no.alias(i8* %8, i64 -1, i8* %11, i64 -1, metadata !"C:\\Users\\NeilHenning\\Home\\burst\\src\\Burst.Compiler.IL.Tests\\Shared\\083-Aliasing.cs(229,9): ") #0<br>
  ret void<br>
}<br>
*** IR Dump After SROA ***<br>
; Function Attrs: nounwind<br>
define dllexport void @"Burst.Compiler.IL.Tests.Aliasing.CheckInlinedFunctionPreservesAliasing(ref Burst.Compiler.IL.Tests.Aliasing.NoAliasWithContentsStruct s)_862A52BC559AC318"(%"Burst.Compiler.IL.Tests.Aliasing/NoAliasWithContentsStruct"* nocapture nonnull
 readonly %s) local_unnamed_addr #0 !ubaa. !1 {<br>
entry:<br>
  %0 = bitcast %"Burst.Compiler.IL.Tests.Aliasing/NoAliasWithContentsStruct"* %s to i64*<br>
  %1 = load i64, i64* %0, align 1<br>
  %2 = getelementptr %"Burst.Compiler.IL.Tests.Aliasing/NoAliasWithContentsStruct", %"Burst.Compiler.IL.Tests.Aliasing/NoAliasWithContentsStruct"* %s, i64 0, i32 1<br>
  %3 = bitcast i8** %2 to i64*<br>
  %4 = load i64, i64* %3, align 1<br>
  %5 = inttoptr i64 %1 to i8*<br>
  %6 = inttoptr i64 %4 to i8*<br>
  call void @llvm.ubaa.expect.no.alias(i8* %5, i64 -1, i8* %6, i64 -1, metadata !"C:\\Users\\NeilHenning\\Home\\burst\\src\\Burst.Compiler.IL.Tests\\Shared\\083-Aliasing.cs(229,9): ") #0<br>
  ret void<br>
}</span><o:p></o:p></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">My only workaround I can dream up locally is to run a pass before SROA to do the alias.scope and noalias forwarding myself by looking back through the store...<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Cheers,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-Neil.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><br>
-- <o:p></o:p></p>
<div>
<div>
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" width="100%" style="width:100.0%;border-collapse:collapse">
<tbody>
<tr>
<td valign="top" style="padding:0in 0in 15.0pt 0in">
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" align="left" style="border-collapse:collapse">
<tbody>
<tr>
<td width="64" valign="top" style="width:48.0pt;padding:0in 0in 0in 0in">
<p class="MsoNormal" style="line-height:18.0pt"><span style="font-size:12.5pt;border:solid windowtext 1.0pt;padding:0in"><img border="0" width="64" height="64" style="width:.6666in;height:.6666in" id="_x0000_i1025" src="cid:image001.jpg@01D5CF71.4EFEE780" alt="Image removed by sender."></span><span style="font-size:12.5pt"><o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td valign="top" style="padding:0in 0in 0in 0in">
<div>
<p class="MsoNormal" style="line-height:11.25pt"><b><span style="font-size:10.5pt;font-family:"Arial",sans-serif;color:black">Neil Henning<o:p></o:p></span></b></p>
</div>
</td>
</tr>
<tr>
<td valign="top" style="padding:0in 0in 0in 0in">
<div>
<p class="MsoNormal" style="line-height:11.25pt"><span style="font-size:10.5pt;font-family:"Arial",sans-serif;color:black">Senior Software Engineer Compiler<o:p></o:p></span></p>
</div>
</td>
</tr>
<tr>
<td valign="top" style="padding:0in 0in 0in 0in">
<div>
<p class="MsoNormal" style="line-height:11.25pt"><span style="font-size:9.0pt;font-family:"Arial",sans-serif;color:black"><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__unity.com&d=DwMFaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=ELyOnT0WepII6UnFk-OSzxlGOXXSfAvOLT6E8iPwwJk&m=GSznZd2GUUZ6h5fLXYaTzhCHJwxEUo_GmtRYcMlOqPE&s=LVQA9YOzUMXrvsXSngTfQjveFSvNuRSG_C0S27GAu1w&e=" target="_blank">unity.com</a><o:p></o:p></span></p>
</div>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>