<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 17, 2015, at 2:15 PM, Duncan P. N. Exon Smith <<a href="mailto:dexonsmith@apple.com" class="">dexonsmith@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="Apple-interchange-newline">On 2015 Jun 17, at 14:03, Alex L <<a href="mailto:arphaman@gmail.com" class="">arphaman@gmail.com</a>> wrote:<br class=""><br class=""><br class=""><br class="">2015-06-17 13:52 GMT-07:00 Duncan P. N. Exon Smith <<a href="mailto:dexonsmith@apple.com" class="">dexonsmith@apple.com</a>>:<br class=""><br class=""><blockquote type="cite" class="">On 2015 Jun 17, at 13:20, Alex Lorenz <<a href="mailto:arphaman@gmail.com" class="">arphaman@gmail.com</a>> wrote:<br class=""><br class="">Hi dexonsmith, bob.wilson, bogner,<br class=""><br class="">This patch moves the SlotTracker class out of AsmWriter.cpp into a separate module that's publicly accessible.<br class=""><br class="">This patch would be useful for MIR Serialization, in particular it would enable the MIR parser to parse metadata machine operands. The metadata machine operands are serialized using the familiar '!' <slot> notation, and the MIR parser has to be able to map from slot numbers to the actual metadata nodes. The SlotTracker class would allow the MIRParser to create this mapping.<br class=""></blockquote><br class="">I can see that this would be useful for *writing* .mir files, but I<br class="">don't think you can safely use this for *reading* .mir files.<br class=""><br class="">Metadata slots can be assigned arbitrarily in an LLVM IR file, such as:<br class=""><br class=""> !named = !{!36, !72}<br class=""> !72 = !{!"string"}}<br class=""> !36 = !{!72, !{!{}}}<br class=""><br class="">If you were to parse the module and then run the slot tracker, you'd get:<br class=""><br class=""> !named = !{!1, !2}<br class=""> !1 = !{!2, !3}<br class=""> !2 = !{!"string"}<br class=""> !3 = !{!4}<br class=""> !4 = !{}<br class=""><br class="">or something close to that.<br class=""><br class="">You couldn't safely take an already-parsed Module, run the slot-tracker<br class="">on it, and then parse machine functions that referenced metadata. But<br class="">it sounds like that's what you're suggesting?<br class=""><br class="">This makes sense, yeah this patch wouldn't really work then.<br class=""><br class=""><br class="">Instead, I think you need to:<br class=""><br class="">1. Yes, surface the slot tracker (exactly this patch), but for completely<br class=""> different reasons: so that you can write out correct metadata numbers<br class=""> for metadata references within machine functions, to match the metadata<br class=""> that you wrote out for the LLVM IR.<br class="">2. Use (1) so that the same slots are used when writing LLVM IR portion of<br class=""> MIR as the machine functions.<br class=""><br class="">I don't need to surface the slot tracker then, as I can print out the correct metadata slot numbers by printing the metadata nodes as operands. They create the slot tracker and initialize it for the whole module, so the correct slot numbers are printed.<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Oof, that sounds expensive. Actually, I know it is: I made it expensive,</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">since previously it was just about useless :).</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">This'll be fine for hand-written testcases, but if someone is debugging</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">some crash from a big input, the MIR will take O(N^2) to print (needs to</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">make slots for all metadata every time something prints out a metadata</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">machine operand).</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote><div><br class=""></div><div>Sounds like <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23865&d=AwMFAg&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=pZ6kE9sMEmJDgyueAI3QUnCMCkXuaI6C5H-6Ce--orc&s=KxF1uvRVnDcQT2MNAVthFaz3vfPihdpo9RgaMDVNDfs&e=" class="">https://llvm.org/bugs/show_bug.cgi?id=23865</a> which I filed just yesterday.</div></div><br class=""><div class="">- Matthias</div></body></html>