<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=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<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:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        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;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle19
        {mso-style-type:personal-compose;
        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="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">any idea how aliasing rules in Fortran compare to 'restrict' in C/__restrict in C++ ?<o:p></o:p></p>
<p class="MsoNormal">If they are comparable, [0].[1] could maybe help ?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Greetings,<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">[0] <a href="https://lists.llvm.org/pipermail/llvm-dev/2019-October/135672.html">
https://lists.llvm.org/pipermail/llvm-dev/2019-October/135672.html</a><o:p></o:p></p>
<p class="MsoNormal">[1] <a href="https://reviews.llvm.org/D68484">https://reviews.llvm.org/D68484</a><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>Kelvin Li via llvm-dev<br>
<b>Sent:</b> Tuesday, April 14, 2020 20:21<br>
<b>To:</b> llvm-dev@lists.llvm.org; flang-dev@lists.llvm.org<br>
<b>Subject:</b> [llvm-dev] Represent Fortran alias information in LLVM IR<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:10.0pt;font-family:"Arial",sans-serif">Hi,</span><br>
<br>
<span style="font-size:10.0pt;font-family:"Arial",sans-serif">We, IBM XL Fortran compiler team, is interested in representing Fortran alias information in LLVM IR.  We use the XL Fortran frontend to emit LLVM IR that includes alias information to feed to the
 LLVM in order to create object files.  For the Fortran alias representation in LLVM IR, we considered both TBAA and ScopeAlias/NoAlias metadata approaches, we think that the ScopeAlias/NoAlias metadata is more appropriate for refined alias information for
 Fortran.  The XL Fortran frontend emits the alias info in terms of what other symbols that a symbol alias to.  We experiment a scheme that represents the alias relation in terms of noalias and scope alias metadata in LLVM IR.  An example is shown in the attached
 slides and the full .ll file for the example is also attached.</span><br>
<br>
<span style="font-size:10.0pt;font-family:"Arial",sans-serif">In this experiment, we observe that the performance gain varies from workload to workload, and the extent can be from a few percent to 2X.  The compile time and the size of the IR increase as well.</span><br>
<br>
<span style="font-size:10.0pt;font-family:"Arial",sans-serif">We briefly investigated the possible causes of the long compile time and the large IR size issues.  For the compile-time performance, we observe:</span><br>
<span style="font-size:10.0pt;font-family:"Arial",sans-serif">- Each alias query (ScopedNoAliasAAResult::mayAliasInScopes) involves partitioning a metadata set based on the domains of the metadata elements.  One possible solution is that pre-partitioning the
 metadata sets and maintaining the partitions on updates can help.</span><br>
<span style="font-size:10.0pt;font-family:"Arial",sans-serif">- Intersection of noalias sets is O(n^2) as metadata elements do not have any ordering. Defining some order on the elements can help significantly.</span><br>
<span style="font-size:10.0pt;font-family:"Arial",sans-serif">- Some optimizations do not scale well when the size of the working instruction set increases, e.g. SCEV functions.</span><br>
<br>
<span style="font-size:10.0pt;font-family:"Arial",sans-serif">For the size of LLVM IR, the noalias metadata requires a flattened set of metadata nodes.  A hierarchical representation can reduce memory footprint.</span><br>
<br>
<span style="font-size:10.0pt;font-family:"Arial",sans-serif">With these findings, we would like to start a thread to discuss how to express Fortran alias in LLVM IR.  Any comments and information regarding any previous approaches are welcome.</span><br>
<br>
<br>
<br>
<br>
<span style="font-size:10.0pt;font-family:"Arial",sans-serif"><br>
Thanks,<br>
Kelvin Li</span><br>
<span style="font-size:10.0pt;font-family:"Arial",sans-serif">Tarique Islam<br>
</span><br>
<br>
<br>
<o:p></o:p></p>
</div>
</div>
</body>
</html>