<div dir="ltr"><div><br></div><div><div>Hi Teresa,</div><div><br></div><div>Yes, we plan to have our code at CG directly.<br></div></div><div>We use our own linker. That's the pain. We might only get a partial benefit of thinLTO which occurs at compile time. <br></div><div><div>I will have a close look at the LTO-tests for any useful command-line option.<br></div></div><div><br></div><div>Thanks for the quick response.<br></div><div><br></div><div>Regards,</div><div>Christu</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 13, 2017 at 7:49 PM, Teresa Johnson <span dir="ltr"><<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</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"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Thu, Jul 13, 2017 at 2:54 AM, Christudasan D <span dir="ltr"><<a href="mailto:xander.cd@gmail.com" target="_blank">xander.cd@gmail.com</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"><div>Thank you Teresa.</div><div><br></div><div>Yes, I would like to save the IR (*.bc and/or *.ll) after all optimizations (especially thinLTO) are done and call <b>llc</b> separately. </div><div>Is there any specific document available online to see more about this feature and various command-line switches that a compiler developer can take advantage of?</div><div>It would help us to enable this feature for a custom architecture.<br></div></div></blockquote><div><br></div></span><div>Unfortunately I don't see any documentation online of llvm-lto. I guess the best bet for now is to look at llvm-lto.cpp, or some of the ThinLTO tests in the tree that use it with those options. I assume you plan to use the internal tools just for testing, and eventually hook up your own code generator to the compiler directly? Which linker do you use? Both gold and lld have support for ThinLTO and a newer LTO interface that uses linker resolution information.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Teresa</div></font></span><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div></div><div><br></div><div>Regards,</div><div>Christu</div></div><div class="m_368820169780408031HOEnZb"><div class="m_368820169780408031h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 12, 2017 at 10:55 PM, Teresa Johnson <span dir="ltr"><<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</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"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Wed, Jul 12, 2017 at 10:19 AM, Teresa Johnson <span dir="ltr"><<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</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">Hi Christu,<div><br></div><div>Thanks for the note!</div><div class="gmail_extra"><br><div class="gmail_quote"><span>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></span><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><span><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></span><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</div></div></div></div></blockquote><div><br></div></span><div>Sorry, that last option should be -thinlto-save-temps=foo, where "foo" will be the prefix of the generate temp files (can include a path). You want the foo*.opt.bc files for the output of the opt pipeline in the backends.</div><span><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> 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"><span><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></span>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">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><span class="m_368820169780408031m_5356305703882011769m_-4613232429381855171HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="m_368820169780408031m_5356305703882011769m_-4613232429381855171m_8498939424323361581gmail_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"> <a href="tel:(408)%20460-2413" value="+14084602413" target="_blank">408-460-2413</a></td></tr></tbody></table></span></div>
</font></span></div></div>
</blockquote></span></div><span><br><br clear="all"><div><br></div>-- <br><div class="m_368820169780408031m_5356305703882011769m_-4613232429381855171gmail_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"> <a href="tel:(408)%20460-2413" value="+14084602413" target="_blank">408-460-2413</a></td></tr></tbody></table></span></div>
</span></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div></div></div><div><div class="h5"><br><br clear="all"><div><br></div>-- <br><div class="m_368820169780408031gmail_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></div></div>
</blockquote></div><br></div>