<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 12, 2016 at 6:29 PM, Peter Collingbourne <span dir="ltr"><<a href="mailto:peter@pcc.me.uk" target="_blank">peter@pcc.me.uk</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">Thanks Rafael.<br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Thu, May 12, 2016 at 4:32 PM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span>On 12 May 2016 at 16:13, Peter Collingbourne <<a href="mailto:peter@pcc.me.uk" target="_blank">peter@pcc.me.uk</a>> wrote:<br>
> pcc added a comment.<br>
><br>
> I have updated the patch. I just want to make sure that people are happy with the situation around the ThinLTO API. I've been working on an LTO/ThinLTO API that could be used by both the gold plugin and lld which should address Mehdi's concerns, but it will take some time until that's ready.<br>
><br>
<br>
</span>Sorry I dropped out of this thread.<br>
<br>
I don't known a lot about ThinLTO, so most comments will be generic about LTO.<br>
<br>
The way the existing lib/LTO is implemented is fundamentally different<br>
from what we do in the gold plugin or lld. We want to make sure we<br>
don't even read and copy symbols if the linker decided to not keep it.<br>
The lib/LTO interface is designed to talk about symbols in the merged<br>
module.<br></blockquote><div><br></div></span><div>Right, I certainly don't want to use any of the existing lib/LTO anywhere we're not using it now. The new API I'm working on deals with symbols in individual modules.</div><span class=""><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
Having said that, I dislike duplicated code as much as anyone else.<br>
That is why I really don't want lld calling into Linker::linkModules:<br>
it duplicates symbol resolution. The same goes for the call to<br>
addPassesToEmitFile. We really should figure out a single place to<br>
populate the pipeline.<br>
<br>
If it is possible for lld/gold/LTO to share more code, excellent but:<br>
<br>
* I would probably not put that in lib/LTO. Lets keep that just for<br>
the existing api.<br></blockquote><div><br></div></span><div>Putting the new API in some other lib makes sense to me.</div><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
* It still seems a bit early for this. We still having more basic<br>
things to finish in lld and the thinLTO api is still moving.<br></blockquote><div><br></div></span><div><div>Regarding the new API, I think there’s a secondary reason why we might want to introduce it sooner rather than later. That reason is that we plan to store symbol resolutions in a combined module index, which basically describes which module contains the prevailing definition of each function. Getting this right is basically a critical correctness issue, as we could otherwise for example import the definition of a weak symbol instead of the prevailing strong symbol. I also understand that Teresa plans to use this information in distributed backends.</div><div><br></div><div>One way we could implement this could be to expose gold's symbol resolutions to the ThinLTO importer in some form. The problem with this is that it adds more complexity in a gold-specific layer, when we know that we will eventually need to deal with that in every linker. Or we could implement symbol resolution ourselves in the importer via the linkage info in the summaries, but as I’m sure you are aware, this would be duplicating logic from the linker. </div></div></div></div></div></blockquote><div><br></div><div>Note that this is the current approach taken by libLTO for ODR resolution in ThinLTO.</div><div><br></div><div>This intersects with what I have been working on today towards the goal of function importing via the gold-plugin (and lld) using the IRMover directly instead of the ModuleLinker, which it currently relies on for lazy importing of linkonce. That requires comdat summary info (specifically for supporting COFF size based comdat selection types). I was then going to refactor and extend the linkonce -> weak resolution being done in ThinLTOCodeGenerator into the function importer. </div><div><br></div><div>If we will get the symbol resolution from the linker (via the index for distributed backends) then we presumably don't need the comdat summary info, unless I am missing something (the linker should take care of marking all comdat members as prevailing I think). If this is the direction then I should put that on hold. The linkonce->weak resolution still needs to be refactored out of ThinLTOCodeGenerator but it would be based on the resolution info rather than the summary linkage types.</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"><div class="gmail_extra"><div class="gmail_quote"><div><div>That’s why I feel it’s best to have the importer deal with linker-agnostic symbol resolution info.</div><div><br></div><div>Getting this right in the gold plugin is basically orthogonal to whether we implement anything in lld. So, the course of action I was considering was</div><div>1) Get the new interface in place, and port the gold plugin to it;</div><div>2) (in parallel with 1) Polish regular LTO in lld as necessary;</div><div>3) Port lld to the new interface.</div></div><div>4) (low priority for me, but maybe Mehdi can help) Port libLTO to the new interface.</div><div><br></div><div>Thanks,</div></div><span class="HOEnZb"><font color="#888888">-- <br><div><div dir="ltr">-- <div>Peter</div></div></div>
</font></span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="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>