<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 11, 2017 at 9:08 AM, Mehdi AMINI <span dir="ltr"><<a href="mailto:joker.eph@gmail.com" target="_blank">joker.eph@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><br><div class="gmail_quote"><span class=""><div>On Tue, Jul 11, 2017 at 8:03 AM Teresa Johnson <<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="gmail_extra"><div class="gmail_quote">On Mon, Jul 10, 2017 at 12:51 PM, Peter Collingbourne <span><<a href="mailto:peter@pcc.me.uk" target="_blank">peter@pcc.me.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="gmail_extra"><div class="gmail_quote"><span class="m_-4961015162372416283m_6040649693949562676gmail-">On Mon, Jul 10, 2017 at 12:37 PM, Teresa Johnson <span><<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Mon, Jul 10, 2017 at 12:30 PM, Peter Collingbourne via Phabricator <span><<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">pcc added a comment.<br>
<span class="m_-4961015162372416283m_6040649693949562676gmail-m_3352316791733754085m_-1490375058014472153m_-7226308486697307150gmail-"><br>
> the global VST (for the global values we will have in the index) does not.<br>
<br>
</span>Not quite, global VSTs include a reference to the symbol name in the strtab.<br></blockquote><div><br></div></span><div>That's what I was thinking when we chatted about this with Haojie, but it turns out I was wrong. The global VST includes the value id and the bitcode offset of the function definition in the IR:</div><div> <a href="http://llvm-cs.pcc.me.uk/lib/Bitcode/Writer/BitcodeWriter.cpp#2763" target="_blank">http://llvm-cs.pcc.me.uk/lib/<wbr>Bitcode/Writer/BitcodeWriter.<wbr>cpp#2763</a></div><div><br></div><div>The offset to the symbol name is included in the MODULE_CODE_FUNCTION entry:</div><div><a href="http://llvm-cs.pcc.me.uk/lib/Bitcode/Writer/BitcodeWriter.cpp#1170" target="_blank">http://llvm-cs.pcc.me.uk/lib/<wbr>Bitcode/Writer/BitcodeWriter.<wbr>cpp#1170</a><br></div><div>which is not really in the global VST.</div></div></div></div></blockquote><div><br></div></span><div>Of course, I totally forgot about that.</div><div><br></div><div>I wonder whether it would be better to emit MODULE_CODE_FUNCTION (etc.) records into the minimised bitcode file, but of length 5 so that they include only the name and the linkage. Then there will be no special handling required in the index bitcode reader.</div></div></div></div></blockquote><div><br></div></div></div></div><div><div class="gmail_extra"><div class="gmail_quote"><div>That is possible too - we could emit the IRSymtab + strtab + MODULE_CODE_* records. But note that as soon as we get into the thin link, we just use these to compute the GUIDs and don't need the names at all. So it seems more straightforward to simply emit the ValueId->GUID mapping directly.</div><div><br></div><div>There are a couple of tradeoffs here of course. When we are performing in-process ThinLTO backends, we only have the single original bitcode with IR + summary, and emitting this mapping adds some redundant info that could be computed from the names in the bitcode file. However, it should be a bit faster to simply get the mappings directly from the records being added here.</div><div><br></div><div>In the distributed case, adding these records means the minimized bitcode file only needs the summary entries (+ these new GUID mapping records), and not the IRsymtab+strtab+ MODULE_CODE_* records. Also - since the summary in the original (IR) bitcode file (only fed to the ThinLTO backend processes) is never needed, when emitting a minimized bitcode file for the thin link we can simply skip emission of the summaries (+ these new records) at all in the IR bitcode file.</div></div></div></div><div><div class="gmail_extra"><div class="gmail_quote"><div></div></div></div></div></blockquote><div><br></div></span><div>In the distributed case, isn't the minimum bitcode file the one you send to the linker? While the thinlink does not need names, I thought that the linker will use the symtab to perform its resolution. Am I missing something?</div></div></div></blockquote><div><br></div><div><br></div><div>Ack - yes. You are right. I was thinking about the thin link in isolation. In that case, we need the IRSymtab and strtab otherwise. Haojie - let's chat about it then as we'll need the info to compute the GUIDs in any case.</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><div class="gmail_quote"><span class="HOEnZb"><font color="#888888"><div><br></div><div>-- </div><div>Mehdi</div></font></span><span class=""><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>Teresa</div></div></div></div><div><div class="gmail_extra"><div class="gmail_quote"><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>Peter</div><span class="m_-4961015162372416283m_6040649693949562676gmail-"><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="gmail_extra"><div class="gmail_quote"><span><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<span class="m_-4961015162372416283m_6040649693949562676gmail-m_3352316791733754085m_-1490375058014472153m_-7226308486697307150gmail-"><br>
> But I think infer it from the code in my previous inline comment, it is "we need the name to recompute a GUID for internal symbol promoted to global", correct?<br>
<br>
</span>Names of globals are also necessary for symbol resolution.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D35189" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D35189</a><br>
<br>
<br>
<br>
</blockquote></span></div><br><br clear="all"><span><div><br></div>-- <br><div class="m_-4961015162372416283m_6040649693949562676gmail-m_3352316791733754085m_-1490375058014472153m_-7226308486697307150gmail_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:2px solid rgb(213,15,37)">Teresa Johnson |</td><td nowrap style="border-top:2px solid rgb(51,105,232)"> Software Engineer |</td><td nowrap style="border-top:2px solid rgb(0,153,57)"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top:2px solid rgb(238,178,17)"> <a href="tel:(408)%20460-2413" value="+14084602413" target="_blank">408-460-2413</a></td></tr></tbody></table></span></div>
</span></div></div>
</blockquote></span></div><span class="m_-4961015162372416283m_6040649693949562676gmail-HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="m_-4961015162372416283m_6040649693949562676gmail-m_3352316791733754085m_-1490375058014472153gmail_signature"><div>-- <div>Peter</div></div></div>
</font></span></div></div>
</blockquote></div></div></div><div><div class="gmail_extra"><br><br clear="all"><div><br></div>-- <br><div class="m_-4961015162372416283m_6040649693949562676gmail_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:2px solid rgb(213,15,37)">Teresa Johnson |</td><td nowrap style="border-top:2px solid rgb(51,105,232)"> Software Engineer |</td><td nowrap style="border-top:2px solid rgb(0,153,57)"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top:2px solid rgb(238,178,17)"> <a href="tel:(408)%20460-2413" value="+14084602413" target="_blank">408-460-2413</a></td></tr></tbody></table></span></div>
</div></div></blockquote></span></div></div>
</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>