<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">Le jeu. 3 mai 2018 à 18:16, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> a écrit :<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"><div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Thu, May 3, 2018 at 6:03 PM Mehdi AMINI <<a href="mailto:joker.eph@gmail.com" target="_blank">joker.eph@gmail.com</a>> wrote:<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"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">Le jeu. 3 mai 2018 à 15:52, Peter Collingbourne <<a href="mailto:peter@pcc.me.uk" target="_blank">peter@pcc.me.uk</a>> a écrit :<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"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 3, 2018 at 3:29 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@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"><div dir="ltr"><br><br><div class="gmail_quote"><span><div dir="ltr">On Thu, May 3, 2018 at 3:08 PM Peter Collingbourne via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<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"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, May 3, 2018 at 2:44 PM, 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br><br><div class="gmail_quote"><span><div dir="ltr">Le mar. 1 mai 2018 à 16:50, Teresa Johnson <<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a>> a écrit :<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"><div dir="ltr">Hi Mehdi, thanks for the comments, responses and a tweaked proposal below. Teresa<div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 1, 2018 at 11:37 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>My main concern is this one:</div><span><div><br></div><div>> Currently, I am emitting the summary entries at the end, after the metadata nodes. Note that the ModuleSummaryIndex is not currently referenced from the Module, and isn’t currently created when parsing the Module IR bitcode (there is a separate derived class for reading the ModuleSummaryIndex from bitcode). This is because they are not currently used at the same time. However, in the future there is no reason why we couldn’t tag the global values in the Module’s LLVM assembly with the corresponding summary entry if the ModuleSummaryIndex is available when printing the Module in the assembly writer. I.e. we could do the following for “main” from the above example when printing the IR definition (note the “^3” at the end):</div><div><br></div><div><br></div></span><div>I believe the reason that the ModuleSummaryIndex is not attached to the Module is that it is fundamentally not a piece of IR, but it is conceptually really an Analysis result.</div><div>Usually other analyses don't serialize their result, we happen to serialize this one for an optimization purpose (reloading it and making the thin-link faster).</div></div></blockquote><div><br></div><div>True. My understanding is that the push for having it serialized via assembly is due to the fact that it is emitted into the bitcode. I know there is disagreement on this reasoning, I am hoping to have a proposal that is acceptable to everyone. =)</div><div><br></div><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"><div dir="ltr"><div>The fundamental problem is that an analysis result has to be able to be invalidated with IR changes, attaching this directly to the module wouldn't achieve this. The risk is that when the IR and the summary get out-of-sync (`clang -O2 my_module_with_summaries.ll -emit-llvm -o my_optimized module_with_summaries.ll`) the summaries would be badly wrong.</div><div><br></div><div>Have you looked into what it'd take to make it a "real" analysis in the pass manager?</div></div></blockquote><div><br></div><div>Thanks for raising this issue specifically, I hadn't addressed it in my proposal and it is a big one. I am not proposing that we attempt to maintain the summary through optimization passes, and definitely don't think we should do that. IMO deserializing it should be for testing the thin link and the combined summaries in the backends only. To that end, I have an idea (below some background first).</div><div><br></div><div>Note that in some cases the module summary analysis is an analysis pass. I.e. when invoked by "opt -module-summary=". However, some time ago when Peter added the support for splitting the bitcode (for CFI purposes) and therefore needed to generate a summary in each partition (Thin and Regular), he added the ThinLTOBitcodeWriterPass, which invokes the module summary builder directly (twice). This writer is what gets invoked now when building via "clang -flto=thin", and with "opt -thinlto-bc". So there it is not invoked/maintained as an analysis pass/result. It would be tricky to figure out how to even split rather than recompute the module summary index in that case. Even in the case where we are still invoking as an analysis pass (opt -module-summary), we would need to figure out how to read in the module summary to use as the analysis result when available (so that it could be invalidated and recomputed when stale).</div><div><br></div><div>Rather than add this plumbing, and just have it discarded if opt does any optimization, I think we should focus at least for the time being on supporting reading the summary from assembly exactly where we currently read in the summary from bitcode:</div><div>1) For the thin link (e.g. tools such as llvm-lto2 or llvm-lto, which currently have to be preceded by "opt -module-summary/-thinlto-bc" to generate an index, but could just build it from assembly instead).</div><div>2) For the LTO backends (e.g. tools such as llvm-lto which can consume a combined index and invoke the backends, or "clang -fthinlto-index=" for distributed ThinLTO backend testing), where we could build the combined summary index from assembly instead.</div><div><br></div><div>This greatly simplifies the reading side, as there are no optimizations performed on the IR after the index is read in these cases that would require invalidation. It also simplifies adding the parsing support, since it gets invoked exactly where we expect to build an index currently (i.e. since we don't currently build or store the ModuleSummaryIndex when parsing the Module from bitcode). It doesn't preclude someone from figuring out how to compute the module summary analysis result from the assembly, and invalidating it after optimization, when reading the Module IR via 'opt' in the future.</div><div><br></div><div>Does this seem like a reasonable proposal to everyone?</div></div></div></div></div></blockquote><div><br></div></span><div>Sounds good to me.</div><div><br></div><div>That would make .ll files quite convenient during debugging I think? We could disassemble, manually change summaries, and re-assemble a bitcode file before running the (thin-)link again.<br></div></div></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Yes, that seems more reasonable than what I thought you had in mind. If the only consumer of this information is llvm-as, then the purpose of the asm summary format is just to provide a way to create a .bc file for testing purposes, which is certainly a useful capability.</div></div></div></div></blockquote></span><div><br>That feels a bit surprising if ".ll -> llvm-as -> .bc -> <some other tool - opt, etc>" is different from ".ll -> <opt, etc>". Is that what we're talking about here? Any chance that can be avoided & feeding a .ll file works (in the sense of does the same thing/tests the same behavior) in all the same places that feeding a .bc file does? (as is the case with non-summary-based IR, to the best of my knowledge)<br></div></div></div></blockquote><div><br></div><div>I may be mistaken, but I don't think we have a lot of tools that can read both .ll and .bc and end up using the summary if it is a .bc file. LTO can't read .ll, for example. The only one that I can think of is clang and presumably we could make that use whichever API we would use in llvm-as for reading the summary from .ll. So the behaviour of most tools would be that ".ll -> llvm-as -> .bc -> <some tool>" vs ".ll -> <some tool>" would end up being the same in both cases: the summary gets discarded.</div></div></div></div></blockquote><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>There is still a discrepancy in that:</div></div></div><div dir="ltr"><div class="gmail_quote"><div><br></div><div> .ll -> llvm-as -> .bc<br></div><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>would be different from:</div><div><br></div><div> .ll -> opt -> .bc<br></div><div><br></div><div>The latter would drop the summary.</div></div></div></blockquote><div><br>Though by the sounds of it .bc -> opt -> .bc drops the summary already? So there's some consistency there.<br></div></div></div></blockquote><div><br></div><div>But that's the current situation, the proposal introduces a new inconsistency.</div><div><br></div><div>Talking to Justin (CC) yesterday at the social, he mentioned that we could have the logic in `opt` so that when no optimization are set it'd operate like llvm-as.</div><div><br></div><div>We could have both:</div><div><br></div><div> .ll -> opt -> .bc<br></div><div> .bc -> opt -> .bc<br></div><div><br></div><div>Behaving the same way as llvm-as and not dropping the summaries.</div><div><br></div><div>-- </div><div>Mehdi</div><div><br></div><div><br></div><div><br></div><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"><div dir="ltr"><div class="gmail_quote"><div><br>But, yeah, it's not clear to me if it'd be better if that did something else. This is mostly/purely for testing/development purposes anyway.<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"><div dir="ltr"><div class="gmail_quote"><div><br></div><div>-- </div><div>Mehdi</div></div></div><div dir="ltr"><div class="gmail_quote"><div><br></div><div><br></div><div><br></div><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"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>Peter</div><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"><div dir="ltr"><div class="gmail_quote"><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"><div><div class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267h5"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>Peter</div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><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"><div dir="ltr"><div class="gmail_quote"><div></div><div><br></div><div>Thanks,</div><span class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095HOEnZb"><font color="#888888"><div><br></div><div>-- </div><div>Mehdi</div></font></span><div><div class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095h5"><div><br></div><div><br></div><div><br></div><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"><div dir="ltr"><div><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>Thanks,</div><div>Teresa</div><div><br></div><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"><div dir="ltr"><div><br></div><div>Cheers,</div><span class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550HOEnZb"><font color="#888888"><div><br></div><div>-- </div><div>Mehdi</div><div><br></div><div><br></div><div><br></div></font></span></div><div class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550HOEnZb"><div class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550h5"><br><div class="gmail_quote"><div dir="ltr">Le mar. 1 mai 2018 à 11:10, Peter Collingbourne <<a href="mailto:peter@pcc.me.uk" target="_blank">peter@pcc.me.uk</a>> a écrit :<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"><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-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br><br><div class="gmail_quote"><div><div class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-h5"><div dir="ltr">On Mon, Apr 30, 2018 at 10:21 AM Peter Collingbourne <<a href="mailto:peter@pcc.me.uk" target="_blank">peter@pcc.me.uk</a>> wrote:<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"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Apr 30, 2018 at 8:32 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-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Peter,<div>Thanks for your comments, replies below.</div><div>Teresa<br><br><div class="gmail_quote"><span class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-"><div dir="ltr">On Wed, Apr 25, 2018 at 2:08 PM Peter Collingbourne <<a href="mailto:peter@pcc.me.uk" target="_blank">peter@pcc.me.uk</a>> wrote:<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"><div dir="ltr">Hi Teresa,<div><br></div><div>Thanks for sending this proposal out.</div><div><br></div><div>I would again like to register my disagreement with the whole idea of writing summaries in LLVM assembly format. In my view it is clear that this is not the right direction, as it only invites additional complexity and more ways for things to go wrong for no real benefit. However, I don't have the energy to argue that point any further, so I won't stand in the way here.</div></div></blockquote><div><br></div></span><div>I assume you are most concerned with the re-assembly/deserialization of the summary. My main goal is to get this dumped into a text format, and I went this route since the last dumper RFC was blocked with the LLVM assembly direction pushed.</div></div></div></div></blockquote><div><br></div><div>Yes, my main concern is with the deserialization. My view is that it should only be allowed for combined summaries -- allowing it for per-module is unnecessary as it creates the possibility of things gettting out of sync. Given that, we don't actually need an assembly representation and we can use whichever format is most convenient. But given the opposition to this viewpoint I am willing to concede getting the format (IMHO) right in favour of something that is acceptable to others, just so that we can test things in a more reasonable way.</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"><div dir="ltr"><div><div class="gmail_quote"><div><div class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-h5"><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"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 24, 2018 at 7:43 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-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi everyone,<div><br></div><div>I started working on a long-standing request to have the summary dumped in a readable format to text, and specifically to emit to LLVM assembly. Proposal below, please let me know your thoughts.</div><div><br></div><div>Thanks,</div><div>Teresa</div><div><br></div><div><b style="font-weight:normal" id="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-docs-internal-guid-737316de-f81b-6dbe-8709-b6a8255a9c91"><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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">RFC: LLVM Assembly format for ThinLTO Summary</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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">========================================</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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Background</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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">-----------------</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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">ThinLTO operates on small summaries computed during the compile step (i.e. with “-c -flto=thin”), which are then analyzed and updated during the Thin Link stage, and utilized to perform IR updates during the post-link ThinLTO backends. The summaries are emitted as LLVM Bitcode, however, not currently in the LLVM assembly.</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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">There are two ways to generate a bitcode file containing summary records for a module:</span></p><ol style="margin-top:0pt;margin-bottom:0pt"><li dir="ltr" style="list-style-type:decimal;font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Compile with “clang -c -flto=thin”</span></p></li><li dir="ltr" style="list-style-type:decimal;font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Build from LLVM assembly using “opt -module-summary”</span></p></li></ol><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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Either of these will result in the ModuleSummaryIndex analysis pass (which builds the summary index in memory for a module) to be added to the pipeline just before bitcode emission.</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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Additionally, a combined index is created by merging all the per-module indexes during the Thin Link, which is optionally emitted as a bitcode file.</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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Currently, the only way to view these records is via “llvm-bcanalyzer -dump”, then manually decoding the raw bitcode dumps.</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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Relatedly, there is YAML reader/writer support for CFI related summary fields (-wholeprogramdevirt-read-summary and -wholeprogramdevirt-write-summary). Last summer, GSOC student Charles Saternos implemented support to dump the summary in YAML from llvm-lto2 (D34080), including the rest of the summary fields (D34063), however, there was pushback on the related RFC for dumping via YAML or another format rather than emitting as LLVM assembly.</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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Goals:</span></p><br><ol style="margin-top:0pt;margin-bottom:0pt"><li dir="ltr" style="list-style-type:decimal;font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Define LLVM assembly format for summary index</span></p></li><li dir="ltr" style="list-style-type:decimal;font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Define interaction between parsing of summary from LLVM assembly and synthesis of new summary index from IR.</span></p></li><li dir="ltr" style="list-style-type:decimal;font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Implement printing and parsing of summary index LLVM assembly</span></p></li></ol><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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Proposed LLVM Assembly Format</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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">----------------------------------------------</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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">There are several top level data structures within the ModuleSummaryIndex:</span></p><ol style="margin-top:0pt;margin-bottom:0pt"><li dir="ltr" style="list-style-type:decimal;font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">ModulePathStringTable: Holds the paths to the modules summarized in the index (only one entry for per-module indexes and multiple in the combined index), along with their hashes (for incremental builds and global promotion).</span></p></li><li dir="ltr" style="list-style-type:decimal;font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">GlobalValueMap: A map from global value GUIDs to the corresponding function/variable/alias summary (or summaries for the combined index and weak linkage).</span></p></li><li dir="ltr" style="list-style-type:decimal;font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">CFI-related data structures (TypeIdMap, CfiFunctionDefs, and CfiFunctionDecls)</span></p></li></ol><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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">I have a WIP patch to AsmWriter.cpp to print the ModuleSummaryIndex that I was using to play with the format. It currently prints 1 and 2 above. I’ve left the CFI related summary data structures as a TODO for now, until the format is at least conceptually agreed, but from looking at those I don’t see an issue with using the same format (with a note/question for Peter on CFI type test representation below).</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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">I modeled the proposed format on metadata, with a few key differences noted below. Like metadata, I propose enumerating the entries with the SlotTracker, and prefixing them with a special character. Avoiding characters already used in some fashion (i.e. “!” for metadata and “#” for attributes), I initially have chosen “^”. Open to suggestions though.</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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Consider the following example:</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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">extern void foo();</span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-kix-line-break"></span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">int X;</span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-kix-line-break"></span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">int bar() {</span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-kix-line-break"></span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"> foo();</span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-kix-line-break"></span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"> return X;</span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-kix-line-break"></span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">}</span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-kix-line-break"></span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">void barAlias() __attribute__ ((alias ("bar")));</span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-kix-line-break"></span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">int main() {</span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-kix-line-break"></span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"> barAlias();</span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-kix-line-break"></span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"> return bar();</span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-kix-line-break"></span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">}</span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-kix-line-break"><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-kix-line-break"></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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">The proposed format has one entry per ModulePathStringTable entry and one per GlobalValueMap/GUID, and looks 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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">^0 = module: {path: testA.o, hash: 5487197307045666224}</span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-kix-line-break"></span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">^1 = gv: {guid: 1881667236089500162, name: X, summaries: {variable: {module: ^0, flags: {linkage: common, notEligibleToImport: 0, live: 0, dsoLocal: 1}}}}</span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-kix-line-break"></span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">^2 = gv: {guid: 6699318081062747564, name: foo}</span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-kix-line-break"></span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">^3 = gv: {guid: 15822663052811949562, name: main, summaries: {function: {module: ^0, flags: {linkage: extern, notEligibleToImport: 1, live: 0, dsoLocal: 1}, insts: 5, funcFlags: {readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0}, calls: {{callee: ^5, hotness: unknown}, {callee: ^4, hotness: unknown}}}}}</span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-kix-line-break"></span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">^4 = gv: {guid: 16434608426314478903, name: bar, summaries: {function: {module: ^0, flags: {linkage: extern, notEligibleToImport: 1, live: 0, dsoLocal: 1}, insts: 3, funcFlags: {readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0}, calls: {{callee: ^2, hotness: unknown}}, refs: {^1}}}}</span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-kix-line-break"></span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">^5 = gv: {guid: 18040127437030252312, name: barAlias, summaries: {alias: {module: ^0, flags: {linkage: extern, notEligibleToImport: 0, live: 0, dsoLocal: 1}, aliasee: ^4}}}</span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-kix-line-break"><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-kix-line-break"></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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Like metadata, the fields are tagged (currently using lower camel case, maybe upper camel case would be preferable).</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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">The proposed format has a structure that reflects the data structures in the summary index. For example, consider the entry “^4”. This corresponds to the function “bar”. The entry for that GUID in the GlobalValueMap contains a list of summaries. For per-module summaries such as this, there will be at most one summary (with no summary list for an external function like “foo”). In the combined summary there may be multiple, e.g. in the case of linkonce_odr functions which have definitions in multiple modules. The summary list for bar (“^4”) contains a FunctionSummary, so the summary is tagged “function:”. The FunctionSummary contains both a flags structure (inherited from the base GlobalValueSummary class), and a funcFlags structure (specific to FunctionSummary). It therefore contains a brace-enclosed list of flag tags/values for each.</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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Where a global value summary references another global value summary (e.g. via a call list, reference list, or aliasee), the entry is referenced by its slot. E.g. the alias “barAlias” (“^5”) references its aliasee “bar” as “^4”.</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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Note that in comparison metadata assembly entries tend to be much more decomposed since many metadata fields are themselves metadata (so then entries tend to be shorter with references to other metadata nodes).</span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-kix-line-break"><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail-kix-line-break"></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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Currently, I am emitting the summary entries at the end, after the metadata nodes. Note that the ModuleSummaryIndex is not currently referenced from the Module, and isn’t currently created when parsing the Module IR bitcode (there is a separate derived class for reading the ModuleSummaryIndex from bitcode). This is because they are not currently used at the same time. However, in the future there is no reason why we couldn’t tag the global values in the Module’s LLVM assembly with the corresponding summary entry if the ModuleSummaryIndex is available when printing the Module in the assembly writer. I.e. we could do the following for “main” from the above example when printing the IR definition (note the “^3” at the end):</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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">define dso_local i32 @main() #0 !dbg !17 ^3 {</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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian: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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian: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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian: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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian: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-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div class="gmail_quote"><span class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-"><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"><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)">^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)">^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)">^3 = typeid: {identifier: typeid3, ...}<br></div><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-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_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-"><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><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"><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-width:1px;border-left-style:solid;border-left-color: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_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-"><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)">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)">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)">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)">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)"><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)">Peter</div><br class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-Apple-interchange-newline"> </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"><div dir="ltr"><div class="gmail_quote"><span class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-HOEnZb"><font color="#888888"><br><br>Teresa</font></span><div><div class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-h5"><div><b id="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-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);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-width:1px;border-left-style:solid;border-left-color: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-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div class="gmail_quote"><div><br></div><div>Thanks,</div><div>Teresa</div><div><div class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-h5"><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"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>Peter</div><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"><div dir="ltr"><div><b style="font-weight:normal" id="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Issues when Parsing of Summaries from Assembly</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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">--------------------------------------------------------------------</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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">When reading an LLVM assembly file containing module summary entries, a ModuleSummaryIndex will be created from the entries.</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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Things to consider are the behavior when:</span></p><ul style="margin-top:0pt;margin-bottom:0pt"><li dir="ltr" style="list-style-type:disc;font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Invoked with “opt -module-summary” (which currently builds a new summary index from the IR). Options:</span></p></li><ol style="margin-top:0pt;margin-bottom:0pt"><li dir="ltr" style="list-style-type:lower-alpha;font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">recompute summary and throw away summary in the assembly file</span></p></li><li dir="ltr" style="list-style-type:lower-alpha;font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">ignore -module-summary and build the summary from the LLVM assembly</span></p></li><li dir="ltr" style="list-style-type:lower-alpha;font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">give an error</span></p></li><li dir="ltr" style="list-style-type:lower-alpha;font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">compare the two summaries (one created from the assembly and the new one created by the analysis phase from the IR), and error if they are different.</span></p></li></ol></ul><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;margin-left:36pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">My opinion is to do a), so that the behavior using -module-summary doesn’t change. We also need a way to force building of a fresh module summary for cases where the user has modified the LLVM assembly of the IR (see below).</span></p><br><ul style="margin-top:0pt;margin-bottom:0pt"><li dir="ltr" style="list-style-type:disc;font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">How to handle older LLVM assembly files that don’t contain new summary fields. Options:</span></p></li><ol style="margin-top:0pt;margin-bottom:0pt"><li dir="ltr" style="list-style-type:lower-alpha;font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Force the LLVM assembly file to be recreated with a new summary. I.e. “opt -module-summary -o - | llvm-dis”.</span></p></li><li dir="ltr" style="list-style-type:lower-alpha;font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Auto-upgrade, by silently creating conservative values for the new summary entries.</span></p></li></ol></ul><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;margin-left:36pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">I lean towards b) (when possible) for user-friendliness and to reduce required churn on test inputs.</span></p><br><ul style="margin-top:0pt;margin-bottom:0pt"><li dir="ltr" style="list-style-type:disc;font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><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-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">How to handle partial or incorrect LLVM assembly summary entries. How to handle partial summaries depends in part on how we answer the prior question about auto-upgrading. I think the best option like there is to handle it automatically when possible. However, I do think we should error on glaring errors like obviously missing information. For example, when there is summary data in the LLVM assembly, but summary entries are missing for some global values. E.g. if the user modified the assembly to add a function but forgot to add a corresponding summary entry. We could still have subtle issues (e.g. user adds a new call but forgets to update the caller’s summary call list), but it will be harder to detect those.</span></p></li></ul></b><span class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917HOEnZb"><font color="#888888"><br></font></span></div><span class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917HOEnZb"><font color="#888888"><div><div><br></div>-- <br><div dir="ltr" class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917m_5112085973537410555gmail_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-width:2px;border-top-style:solid;border-top-color:rgb(213,15,37)">Teresa Johnson |</td><td style="border-top-width:2px;border-top-style:solid;border-top-color:rgb(51,105,232)"> Software Engineer |</td><td style="border-top-width:2px;border-top-style:solid;border-top-color:rgb(0,153,57)"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td style="border-top-width:2px;border-top-style:solid;border-top-color: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></font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200m_6567874537655844917gmail_signature"><div dir="ltr">-- <div>Peter</div></div></div>
</div></div>
</blockquote></div></div></div><div><div class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-h5"><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail-m_-8353203249030920200gmail_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-width:2px;border-top-style:solid;border-top-color:rgb(213,15,37)">Teresa Johnson |</td><td style="border-top-width:2px;border-top-style:solid;border-top-color:rgb(51,105,232)"> Software Engineer |</td><td style="border-top-width:2px;border-top-style:solid;border-top-color:rgb(0,153,57)"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td style="border-top-width:2px;border-top-style:solid;border-top-color: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></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786m_4795617359147801528gmail_signature"><div dir="ltr">-- <div>Peter</div></div></div>
</div></div>
</blockquote></div></div></div><div><div class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-h5"><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail-m_-6956089728037873786gmail_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-width:2px;border-top-style:solid;border-top-color:rgb(213,15,37)">Teresa Johnson |</td><td style="border-top-width:2px;border-top-style:solid;border-top-color:rgb(51,105,232)"> Software Engineer |</td><td style="border-top-width:2px;border-top-style:solid;border-top-color:rgb(0,153,57)"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td style="border-top-width:2px;border-top-style:solid;border-top-color: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></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550m_7418588459110944206m_4502817952738636235gmail_signature"><div dir="ltr">-- <div>Peter</div></div></div>
</div></div>
</blockquote></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095m_4269345380332382296m_8921911820903467664m_7729192863744272269m_9036781251802416550gmail_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>
</div></div></div>
</blockquote></div></div></div></div>
</blockquote></div></div></div><div dir="ltr"><div class="gmail_extra"><br><br clear="all"><div><br></div>-- <br><div class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267m_5004165039369931912m_6710373724474087095gmail_signature"><div dir="ltr">-- <div>Peter</div></div></div>
</div></div></div></div><span>
_______________________________________________<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/mailman/listinfo/llvm-dev</a><br>
</span></blockquote></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail-m_-9114116057051773843m_-3144670029993966461gmail-m_-6377244508080862267gmail_signature"><div dir="ltr">-- <div>Peter</div></div></div>
</div></div>
</blockquote></div></div></blockquote></div></div>
</blockquote></div></div>