<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Thu, Feb 16, 2017 at 1:53 PM Konstantin Zhuravlyov 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">kzhuravl 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">
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"></blockquote><div><br></div><div>I'll leave that to Adrian or Duncan, who know more about the bitcode format/tradeoffs, I think.</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">
================<br class="gmail_msg">
Comment at: lib/CodeGen/AsmPrinter/DwarfUnit.cpp:847-848<br class="gmail_msg">
+  // types as DW_AT_address_class.<br class="gmail_msg">
+  if (DTy->getAddressSpace() && (Tag == dwarf::DW_TAG_pointer_type ||<br class="gmail_msg">
+                                 Tag == dwarf::DW_TAG_reference_type))<br class="gmail_msg">
+    addUInt(Buffer, dwarf::DW_AT_address_class, dwarf::DW_FORM_data4,<br class="gmail_msg">
----------------<br class="gmail_msg">
dblaikie wrote:<br class="gmail_msg">
> why only on pointer and reference types? Should we just do it on all types and don't put an address space on osmething in the IR if it's not desired to be in the DWARF?<br class="gmail_msg">
According to dwarf specs [v2-v5], DW_AT_address_class only applies to pointer or reference types, subroutines or subroutine types.</blockquote><div><br></div><div>Then seems reasonable that it shouldn't be present on them in the metadata - this could be enforced by the validator, or I wouldn't terribly mind if the IR allowed this to be expressed and emitted (the DWARF spec doesn't preclude other uses of attributes, I think? I forget how that works)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> I just checked, and DW_AT_address_class is not present in dwarf spec v1. So we should only generate DW_AT_address_class for v2+.<br class="gmail_msg"></blockquote><div><br></div><div>That seems like something that should be checked/handled here (& tested) in the backend.</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">
<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>