<div dir="ltr">Hi Christu,<div><br></div><div>Thanks for the note!</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 12, 2017 at 9:56 AM, Christudasan D via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif">Hello,<span></span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif"><span> </span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif">My impression on <i>thinLTO</i> when
I first heard of it, (EuroLLVM2015) was about achieving Cross
Module Optimization (CMO) at the IR level.<span></span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif"> <span></span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif">Having parallel front-end compilation &
initial optimization first, a thin-link of individual input units, more
optimization by calling opt again on the combined IR, and finally the target codegen
using llc.  <span></span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif"><span> </span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif">A transformation similar to the following:<span></span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif">Input File 1: Clang+opt (with thinLTO)<span></span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif">Input File 2: Clang+opt (with
thinLTO)          
---           
llvm-link      
----       opt (for
CMO)     
---             llc
for target codegen.<span></span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif">                      
…..<span></span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif">Input File n: Clang+opt (with thinLTO)<span></span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif"> <span></span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif">But from the presentation on LLVM
Developers’ Meeting 2016, I believe thinLTO is more than that. The full
advantage of this optimization should require a significant changes in the
backend as well (I suppose).</span></p></div></blockquote><div><br></div><div>Right, the model in the EuroLLVM talk was just an initial prototype that used llvm-link/opt, and yes now we do whole program optimizations during the thin link, beyond just linking in additional IR for inlining etc.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif"><span></span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif"><span> </span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif">Before I post my question, kudos to the
entire team behind thinLTO optimization - Teresa Johnson, Mehdi Amni, Xinliang
David Li, other developers and test engineers across the globe.<span></span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif"><span> </span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif">I am working on the compiler for a target wherein the code
size improvement is a critical factor. We are still using LLVM 3.5 code base. We
assume, by moving to LLVM4.0.0 (with thinLTO and other recent target
independent optimizations) we would be able to improve the codegen to a considerable
number.<span></span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif"> <span></span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif">With thinLTO in LLVM4.0.0 compiler, when we build an application with multiple compilation
units, is it possible to achieve any benefit purely with LLVM IR passes (without
really involving the compiler backend)?<span></span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif">If yes, can anyone provide me the
information about the command-line options and the sequence to call the llvm
components (clang, opt, etc.) to achieve it.</span></p></div></blockquote><div><br></div><div>Do you just want the bitcode out after all optimization passes and before codegen? It is doable with llvm-lto -thinlto-action=run -save-temps I believe (although you will get more bitcode output files than you want, but one of the output bitcode files per input file should be the post-opt pre-codegen bitcode file. The input files to llvm-lto would be bitcode files created by "clang -flto=thin -c -O2 ..."</div><div><br></div><div>Teresa</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif"><span></span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif"><span> </span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif">I truly value any input in this regard.<span></span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif"><span> </span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif">Regards,<span></span></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:9.5pt;font-family:Arial,sans-serif">Christu<span></span></span></p></div>
<br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><span style="font-family:Times;font-size:medium"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Teresa Johnson |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"> 408-460-2413</td></tr></tbody></table></span></div>
</div></div>