<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Apr 18, 2016 at 11:21 AM, Duncan P. N. Exon Smith <span dir="ltr"><<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@apple.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We could probably do it pretty efficiently, allocating the DITypeRef in<br>
a block of some sort.<br>
<br>
I could imagine something pretty low-overhead if it just needs a number<br>
(as opposed to a separate string for each):<br>
--<br>
  class DITypeIndex : public Metadata {<br>
    // Use Metadata::SubclassData32 for a type index?<br>
    // Use Metadata::SubclassData16 as offset to "DITypePrefix", in same<br>
    // allocation?<br>
  };<br>
  static_assert(sizeof(DITypeIndex) == 8);<br>
<br>
  class DITypePrefix {<br>
    DITypePrefix *Chain;  // Chain to others?<br>
    MDString *Name;       // Name/identifier for the prefix.<br>
    DITypeIndex Types[0]; // Co-allocated types.  Maybe in blocks of some<br>
                          // particular size?<br>
  };<br>
--<br>
then in textual IR, make it look like this:<br>
--<br>
!0 = distinct !DILocalVariable(type: !DITypeIndex(name: "abc", index: 7))<br>
--<br>
(where the DITypePrefix is built implicitly).  I don't really know what it<br>
is you need to represent, but it seems something like this wouldn't become<br>
a bottleneck.<br>
<br>
Haven't really thought it through.  This would work well if you know all<br>
the types (the full type prefix) ahead of time; if you're building<br>
something lazily you'd probably need to use temporary MDTuples or<br>
something.</blockquote><div><br></div><div>I have a patch that more or less implements exactly what you described. :)</div><div><br></div><div>It's a DITypeIndex that uses SubclassData32. I'll try to get it posted later today.</div></div></div></div>