<div dir="ltr"><div>Hey Jeroen,</div><div><br></div><div>Ok cool - once I can work out how to apply that patch successfully without using ARC I'll give it a whirl (sidenote: oh how I lament not just being able to use github to pull the PR!).</div><div><br></div><div>Cheers,</div><div>-Neil.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jan 20, 2020 at 8:09 AM Jeroen Dobbelaere <<a href="mailto:Jeroen.Dobbelaere@synopsys.com">Jeroen.Dobbelaere@synopsys.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 lang="EN-US">
<div class="gmail-m_4979142013111611219WordSection1">
<p class="MsoNormal">Hi Neil,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">This should be solved with the 'full restrict patches' <a href="https://reviews.llvm.org/D68484" target="_blank">
https://reviews.llvm.org/D68484</a> : it treats %noalias arguments in a different<u></u><u></u></p>
<p class="MsoNormal">way so that we keep more accurate information during SROA.<u></u><u></u></p>
<p class="MsoNormal">A convenience single patch is available here: <a href="https://reviews.llvm.org/D69542" target="_blank">
https://reviews.llvm.org/D69542</a><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Please let me know, if you happen to try it out, that it indeed solves your problem.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Jeroen Dobbelaere<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border-color:currentcolor currentcolor currentcolor blue;border-style:none none none solid;border-width:medium medium medium 1.5pt;padding:0in 0in 0in 4pt">
<div>
<div style="border-color:rgb(225,225,225) currentcolor currentcolor;border-style:solid none none;border-width:1pt medium medium;padding:3pt 0in 0in">
<p class="MsoNormal"><b>From:</b> llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>> <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 <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Subject:</b> [llvm-dev] Help with SROA throwing away no-alias information<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></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.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></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.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></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?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></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:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></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><u></u><u></u></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal"><u></u> <u></u></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...<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Cheers,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">-Neil.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><br>
-- <u></u><u></u></p>
<div>
<div>
<table style="width:100%;border-collapse:collapse" width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td style="padding:0in 0in 15pt" valign="top">
<table style="border-collapse:collapse" cellspacing="0" cellpadding="0" border="0" align="left">
<tbody>
<tr>
<td style="width:48pt;padding:0in" width="64" valign="top">
<p class="MsoNormal" style="line-height:18pt"><span style="font-size:12.5pt;border:1pt solid windowtext;padding:0in"><img style="width: 0.6666in; height: 0.6666in;" id="gmail-m_4979142013111611219_x0000_i1025" src="cid:16fc29c2fe24ce8e91" alt="Image removed by sender." width="64" height="64" border="0"></span><span style="font-size:12.5pt"><u></u><u></u></span></p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td style="padding:0in" valign="top">
<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<u></u><u></u></span></b></p>
</div>
</td>
</tr>
<tr>
<td style="padding:0in" valign="top">
<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<u></u><u></u></span></p>
</div>
</td>
</tr>
<tr>
<td style="padding:0in" valign="top">
<div>
<p class="MsoNormal" style="line-height:11.25pt"><span style="font-size:9pt;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><u></u><u></u></span></p>
</div>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><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>