<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, May 1, 2018 at 11:10 AM Peter Collingbourne <<a href="mailto:peter@pcc.me.uk">peter@pcc.me.uk</a>> wrote:<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 dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 1, 2018 at 9:00 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div><div class="gmail-m_-1935647154012674877gmail-h5"><div dir="ltr"><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 dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div class="gmail_quote"><div><div class="gmail-m_-1935647154012674877gmail-m_-6956089728037873786m_4795617359147801528gmail-h5"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><b style="font-weight:normal" id="gmail-m_-1935647154012674877gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-docs-internal-guid-737316de-f81b-6dbe-8709-b6a8255a9c91"><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">For CFI data structures, the format would be similar. It appears that TypeIds are referred to by string name in the top level TypeIdMap (std::map indexed by std::string type identifier), whereas they are referenced by GUID within the FunctionSummary class (i.e. the TypeTests vector and the VFuncId structure). For the LLVM assembly I think there should be a top level entry for each TypeIdMap, which lists both the type identifier string and its GUID (followed by its associated information stored in the map), and the TypeTests/VFuncId references on the FunctionSummary entries can reference it by summary slot number. I.e. something like:</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">^1 = typeid: {guid: 12345, identifier: name_of_type, …</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">^2 = gv: {... {function: {.... typeTests: {^1, …</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Peter - is that correct and does that sound ok?</span></p></b></div></div></blockquote><div><br></div><div>I don't think that would work because the purpose of the top-level TypeIdMap is to contain resolutions for each type identifier, and per-module summaries do not contain resolutions (only the combined summary does). What that means in practice is that we would not be able to recover and write out a type identifier name for per-module summaries as part of ^1 in your example (well, we could in principle, because the name is stored somewhere in the function's IR, but that could get complicated).</div></div></div></div></blockquote><div><br></div></div></div><div>Ah ok. I guess the top-level map then is generated by the regular LTO portion of the link (since it presumably requires IR during the Thin Link to get into the combined summary)?</div></div></div></div></blockquote><div><br></div><div>Yes, we fill in the map during the LowerTypeTests and WholeProgramDevirt passes in the regular LTO part of the link, e.g. here:</div><div> <a href="http://llvm-cs.pcc.me.uk/lib/Transforms/IPO/LowerTypeTests.cpp#823" target="_blank">http://llvm-cs.pcc.me.uk/lib/Transforms/IPO/LowerTypeTests.cpp#823</a><br></div><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 dir="ltr"><div><div class="gmail_quote"><span class="gmail-m_-1935647154012674877gmail-m_-6956089728037873786m_4795617359147801528gmail-"><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 dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Probably the easiest thing to do is to keep the type identifiers as GUIDs in the function summaries and write out the mapping of type identifiers as a top-level entity.</div></div></div></div></blockquote><div><br></div></span><div>To confirm, you mean during the compile step create a top-level entity that maps GUID -> identifier?</div></div></div></div></blockquote><div><br></div><div>I mean that you could represent this with something like:</div><div><br></div><div>^typeids = {^1, ^2, ^3}</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">^1 = typeid: {identifier: typeid1, ...}</div><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">^2 = typeid: {identifier: typeid2, ...}</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">^3 = typeid: {identifier: typeid3, ...}<br></div><br class="gmail-m_-1935647154012674877gmail-m_-6956089728037873786m_4795617359147801528gmail-Apple-interchange-newline">There's no need to store the GUIDs here because they can be computed from the type identifiers. The GUIDs would only be stored in the typeTests (etc.) fields in each function summary.</div></div></div></div></blockquote><div><br></div></div></div>I suppose we don't need to store the GUIDs at the top level in the in-memory summary. But I think it would be good to emit the GUIDs in the typeid assembly entries because it makes the association in the assembly much more obvious. I.e. going back to my original example:<span class="gmail-m_-1935647154012674877gmail-"><br><br>^1 = typeid: {guid: 12345, identifier: name_of_type, …<br>^2 = gv: {... {function: {.... typeTests: {^1, …</span></div><div class="gmail_quote"><br>If we didn't include the GUID in the typeid entry, but rather just the identifier, and put the GUID in the typeTest list in the GV's entry, it wouldn't be obvious at all from the assembly listing which typeid goes with which typeTest. It's also less compact to include the GUID in each typeTests list.</div></div></blockquote><div><br></div><div>I get that, but my point was that in a per-module summary the TypeIdMap is empty, so there will be no names, only GUIDs.</div><div><br></div><div>For "making the association more obvious" we might just want to have the assembly writer emit the GUID of a name as a comment.</div></div></div></div></blockquote><div><br></div><div>This is what I have done in the disassembly for the TypeIdMap in a combined index.</div><div>The per-module summaries print the full GUID in the TypeIdInfo entries.</div><div>However, since we do have the TypeIdMap in the combined summary, to make the disassembly more compact and make the association more obvious, I went ahead and used the associated typeid slot number in the TypeIdInfo entries instead of the full GUID. You can see how that looks in the change to the tests in D46700. Let me know what you think.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote">Or perhaps we are saying the same thing - I can't tell from your above example if the GUID is also emitted in the "typeid:" entries.<br></div></div></blockquote><div><br></div><div>No, it wouldn't be.</div><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 dir="ltr"><div class="gmail_quote">I'm not sure there is a need for the:<span class="gmail-m_-1935647154012674877gmail-"><br>^typeids = {^1, ^2, ^3}<br></span>We can just build the typeids list on the fly as " = typeid: " entries are read in.</div></div></blockquote><div><br></div><div>That's true. Given that nothing actually needs to refer to them, we can just represent the typeids as something like </div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">typeid: {identifier: typeid1, ...} ; guid = 123</div><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">typeid: {identifier: typeid2, ...} ; guid = 456</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">typeid: {identifier: typeid3, ...} ; guid = 789<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">without an associated number.</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">Peter</div><br class="gmail-m_-1935647154012674877gmail-Apple-interchange-newline"> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><span class="gmail-m_-1935647154012674877gmail-HOEnZb"><font color="#888888"><br><br>Teresa</font></span><div><div class="gmail-m_-1935647154012674877gmail-h5"><div><b id="gmail-m_-1935647154012674877gmail-m_-6956089728037873786gmail-m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-docs-internal-guid-737316de-f81b-6dbe-8709-b6a8255a9c91" style="font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;font-weight:normal"><p style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><br></p></b></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>Peter</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div class="gmail_quote"><div><br></div></div></div></div></blockquote></div></div></div></blockquote></div></div></div></div></blockquote></div></div></div></blockquote></div>-- <br><div dir="ltr" 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 style="border-top:2px solid rgb(213,15,37)">Teresa Johnson |</td><td style="border-top:2px solid rgb(51,105,232)"> Software Engineer |</td><td style="border-top:2px solid rgb(0,153,57)"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td style="border-top:2px solid rgb(238,178,17)"> 408-460-2413</td></tr></tbody></table></span></div></div>