<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On May 29, 2018, at 12:55, Adrian Prantl <<a href="mailto:aprantl@apple.com" class="">aprantl@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration: none;" class=""><br class="Apple-interchange-newline"><br class=""><blockquote type="cite" class=""><div class="">On May 29, 2018, at 12:28 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">+some of the debug info cabal (& Duncan, as an emeritus member, and person who plumbed a lot of the current debug info syntax support in)<br class=""><br class="">Visitor seems plausible though I haven't looked at the code in detail to see if it'd work perfectly.<br class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Tue, May 29, 2018 at 7:56 AM Sohail Somani (Fizz Buzz Inc.) via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:<br class=""></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;"><u class=""></u><div class="">[Resending due to accidental markdown rendering - sorry]<br class=""><br class=""><div class="" style="font-family: Arial;">Hi list,<br class=""></div><div class="" style="font-family: Arial;"><br class=""></div><div class="" style="font-family: Arial;">Let's talk about adding a new type of debug info metadata. Here are the steps (at minimum - probably incomplete) one needs to take:<br class=""></div><div class="" style="font-family: Arial;"><br class=""></div><div class="" style="font-family: Arial;">1. Create a new class in the hierarchy<br class=""></div><div class="" style="font-family: Arial;">2. Implement two forms of `MD_NODE_GET`<br class=""></div><div class="" style="font-family: Arial;">3. Specialize `MDNodeKeyImpl`<br class=""></div><div class="" style="font-family: Arial;">4. Modify `LLParser.cpp` and add serialization code for your special type<br class=""></div><div class="" style="font-family: Arial;">5. Modify `AsmWriter.cpp` and add serialization code for your special type <br class=""></div><div class="" style="font-family: Arial;"><br class=""></div><div class="" style="font-family: Arial;">I believe we can accomplish everything needed for debug info with just step 1 using a pattern found in Boost Serialization. Imagine a new API based on this concept:<br class=""></div><div class="" style="font-family: Arial;"><br class=""></div><div class="" style="font-family: Arial;">```<br class=""></div><div class="" style="font-family: Arial;">class DIMyFancyType : public MDNode {<br class=""></div><div class="" style="font-family: Arial;">  StringRef FileName;<br class=""></div><div class="" style="font-family: Arial;"><br class=""></div><div class="" style="font-family: Arial;">  template<typename Visitor><br class=""></div><div class="" style="font-family: Arial;">  void visit(Visitor & v) {<br class="">     DINode::visit(s); // or not, if you stay true to boost.serialization</div><div class="" style="font-family: Arial;">     <a href="http://v.name/" target="_blank" class="">v.name</a>("DIMyFancyType");</div><div class="" style="font-family: Arial;">     v.property("FileName",FileName);<br class="">  }<br class="">};</div><div class="" style="font-family: Arial;">```<br class=""></div><div class="" style="font-family: Arial;"><br class=""></div><div class="" style="font-family: Arial;">With this, we could implement steps 2-5 using a little bit of template meta-programming and we could also implement escape hatches where needed to get more specific, allowing us to keep many things in one place.</div><div class="" style="font-family: Arial;"><br class=""></div><div class="" style="font-family: Arial;">I imagine since there is now a `.def` file for the metadata (very useful!) that this is on somebody's mind and not just my own, so I'm curious about what people think. I realize that "new forms of debug metadata" is possibly not a very popular use case as there has been only one new kind added in the last few years. However, in my humble opinion, it would make it easier to add richer information allowing those of us extending LLVM to create better debuggers/debugging experiences.</div></div></blockquote></div></div></div></blockquote></div></div></blockquote><div><br class=""></div><div>SGTM!  There was a hope (not quite a plan) that these would eventually be tablegen'ed, but visitor sounds fine to me too.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration: none;" class=""><div class="">Something (anything) along these lines seems like a good idea to me. In addition to the cost of adding new nodes, having less repetitive manually-written existing code reduces the chances for bugs and increases readability. There are some irregularities in the existing code that I'm aware of that would need to be still handled separately:</div><div class="">- The <span class="" style="font-family: Arial;">MDNodeKeyImpl currently is manually tuned to only hash members that are likely to differ.</span></div><div class=""><span class="" style="font-family: Arial;">- The deserialization code also supports various older serialization formats.</span></div></div></div></blockquote><div><br class=""></div><div>These are the two corner cases I was thinking of.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration: none;" class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_quote"><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 class=""><div class="" style="font-family: Arial;"><br class=""></div><div class="" style="font-family: Arial;">Thanks for your time!</div><div class="" style="font-family: Arial;"><br class=""></div><div id="m_-1482018131165573299sig66433728" class=""><div class="m_-1482018131165573299signature">--<br class=""></div><div class="m_-1482018131165573299signature">Sohail Somani<br class=""></div><div class="m_-1482018131165573299signature">Fizz Buzz Inc.<br class=""></div><div class="m_-1482018131165573299signature">Booking schedule: <a href="https://sohailsomani.youcanbook.me/" target="_blank" class="">https://sohailsomani.youcanbook.me</a></div></div><div class="" style="font-family: Arial;"><br class=""></div></div>_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class=""></blockquote></div></div></div></blockquote></div><br class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration: none;"><br class="Apple-interchange-newline"></div></blockquote></div><br class=""></body></html>