<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Thu, Feb 16, 2017 at 2:10 PM Adrian Prantl via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">aprantl added inline comments.<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
================<br class="gmail_msg">
Comment at: lib/Bitcode/Reader/MetadataLoader.cpp:1117<br class="gmail_msg">
+    Optional<unsigned> AddressSpace = None;<br class="gmail_msg">
+    if (Record.size() > 12 && Record[12] != ~0U)<br class="gmail_msg">
+      AddressSpace = Record[12];<br class="gmail_msg">
----------------<br class="gmail_msg">
kzhuravl wrote:<br class="gmail_msg">
> dblaikie wrote:<br class="gmail_msg">
> > What's the magical ~0U value about?<br class="gmail_msg">
> I used it as a sentinel value to represent "None" optional dwarf address space in the bitcode (we always generate and read address space record, if it is ~0U, then we pass None when creating DIDerivedType).<br class="gmail_msg">
><br class="gmail_msg">
> Would it be better to not write address space record if it is None?<br class="gmail_msg">
><br class="gmail_msg">
> We can also use UINT24_MAX + 1 (we would need to define UINT24_MAX). or ADDRESS_SPACE_MAX?<br class="gmail_msg">
I'm pretty sure we prefer bitcode records from the same LLVM revision to always have the same number of elements.<br class="gmail_msg">
Typically we use 0 as the default value and omit it in the textual IR.<br class="gmail_msg">
What would you think about encoding the address space as n+1, with 0 being the default=None value?<br class="gmail_msg"></blockquote><div><br></div><div>I was going to say that seems a bit ugly (compared to using max value as the marker) - but then rememered the bitcode format uses variable length encoding, so encoding the max value probably isn't as cheap as zero, I guess?<br><br>- Dave</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br class="gmail_msg">
<br class="gmail_msg">
<a href="https://reviews.llvm.org/D29670" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D29670</a><br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
</blockquote></div></div>