<span style=" font-size:10pt;font-family:sans-serif">Hi Jeroen,</span><br><br><span style=" font-size:10pt;font-family:sans-serif">As far as I know,
some dummy arguments in Fortran have the restrict property.  </span><br><br><span style=" font-size:10pt;font-family:sans-serif">Thanks for the
information.  We were pointed to your patch during the last Flang
technical call when we presented our work. We are still going thru it and
we will definitely look into if it helps Fortran alias. By the way, the
Flang technical meeting will continue to discuss Fortran alias topic next
Monday (Apr 20, 2020 @ 11:30 EDT).  Hope that you can join and provide
your insight.<br></span><br><span style=" font-size:10pt;font-family:sans-serif">Thanks,<br>Kelvin<br></span><br><br><br><br><span style=" font-size:9pt;color:#5f5f5f;font-family:sans-serif">From:
       </span><span style=" font-size:9pt;font-family:sans-serif">Jeroen
Dobbelaere <Jeroen.Dobbelaere@synopsys.com></span><br><span style=" font-size:9pt;color:#5f5f5f;font-family:sans-serif">To:
       </span><span style=" font-size:9pt;font-family:sans-serif">Kelvin
Li <kli@ca.ibm.com>, "flang-dev@lists.llvm.org" <flang-dev@lists.llvm.org>,
"llvm-dev@lists.llvm.org" <llvm-dev@lists.llvm.org></span><br><span style=" font-size:9pt;color:#5f5f5f;font-family:sans-serif">Date:
       </span><span style=" font-size:9pt;font-family:sans-serif">2020/04/15
12:08 PM</span><br><span style=" font-size:9pt;color:#5f5f5f;font-family:sans-serif">Subject:
       </span><span style=" font-size:9pt;font-family:sans-serif">[EXTERNAL]
RE: [llvm-dev] Represent Fortran alias information in LLVM IR</span><br><hr noshade><br><br><p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;font-family:Calibri">Hi,</span></p><p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;font-family:Calibri"> </span></p><p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;font-family:Calibri">any
idea how aliasing rules in Fortran compare to 'restrict' in C/__restrict
in C++ ?</span></p><p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;font-family:Calibri">If
they are comparable, [0].[1] could maybe help ?</span></p><p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;font-family:Calibri"> </span></p><p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;font-family:Calibri">Greetings,</span></p><p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;font-family:Calibri"> </span></p><p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;font-family:Calibri">Jeroen
Dobbelaere</span></p><p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;font-family:Calibri"> </span></p><p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;font-family:Calibri">[0]
</span><a href="https://lists.llvm.org/pipermail/llvm-dev/2019-October/135672.html"><span style=" font-size:11pt;color:#0082bf;font-family:Calibri"><u>https://lists.llvm.org/pipermail/llvm-dev/2019-October/135672.html</u></span></a></p><p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;font-family:Calibri">[1]
</span><a href="https://reviews.llvm.org/D68484"><span style=" font-size:11pt;color:#0082bf;font-family:Calibri"><u>https://reviews.llvm.org/D68484</u></span></a></p><p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;font-family:Calibri"> </span></p><p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;font-family:Calibri"> </span></p><p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;font-family:Calibri"><b>From:</b>llvm-dev <llvm-dev-bounces@lists.llvm.org> <b>On Behalf Of </b>Kelvin
Li via llvm-dev<b><br>Sent:</b> Tuesday, April 14, 2020 20:21<b><br>To:</b> llvm-dev@lists.llvm.org; flang-dev@lists.llvm.org<b><br>Subject:</b> [llvm-dev] Represent Fortran alias information in LLVM IR</span></p><p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;font-family:Calibri"> </span></p><p style="margin-top:0px;margin-Bottom:240px"><span style=" font-size:10pt;font-family:Arial">Hi,</span><span style=" font-size:11pt;font-family:Calibri"><br></span><span style=" font-size:10pt;font-family:Arial"><br>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><span style=" font-size:11pt;font-family:Calibri"><br></span><span style=" font-size:10pt;font-family:Arial"><br>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><span style=" font-size:11pt;font-family:Calibri"><br></span><span style=" font-size:10pt;font-family:Arial"><br>We briefly investigated the possible causes of the long compile time and
the large IR size issues.  For the compile-time performance, we observe:<br>- 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.<br>- 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.<br>- Some optimizations do not scale well when the size of the working instruction
set increases, e.g. SCEV functions.</span><span style=" font-size:11pt;font-family:Calibri"><br></span><span style=" font-size:10pt;font-family:Arial"><br>For the size of LLVM IR, the noalias metadata requires a flattened set
of metadata nodes.  A hierarchical representation can reduce memory
footprint.</span><span style=" font-size:11pt;font-family:Calibri"><br></span><span style=" font-size:10pt;font-family:Arial"><br>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><span style=" font-size:11pt;font-family:Calibri"><br><br><br><br></span><span style=" font-size:10pt;font-family:Arial"><br><br>Thanks,<br>Kelvin Li<br>Tarique Islam</span><span style=" font-size:11pt;font-family:Calibri"><br><br><br></span></p><p style="margin-top:0px;margin-Bottom:240px"></p><p style="margin-top:0px;margin-Bottom:240px"></p><BR>