[PATCH] D29670: [DebugInfo] Emit address space with DW_AT_address_class attribute for pointer and reference types

Konstantin Zhuravlyov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 16 13:53:10 PST 2017


kzhuravl added inline comments.


================
Comment at: lib/Bitcode/Reader/MetadataLoader.cpp:1117
+    Optional<unsigned> AddressSpace = None;
+    if (Record.size() > 12 && Record[12] != ~0U)
+      AddressSpace = Record[12];
----------------
dblaikie wrote:
> What's the magical ~0U value about?
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).

Would it be better to not write address space record if it is None?

We can also use UINT24_MAX + 1 (we would need to define UINT24_MAX). or ADDRESS_SPACE_MAX?


================
Comment at: lib/CodeGen/AsmPrinter/DwarfUnit.cpp:847-848
+  // types as DW_AT_address_class.
+  if (DTy->getAddressSpace() && (Tag == dwarf::DW_TAG_pointer_type ||
+                                 Tag == dwarf::DW_TAG_reference_type))
+    addUInt(Buffer, dwarf::DW_AT_address_class, dwarf::DW_FORM_data4,
----------------
dblaikie wrote:
> 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?
According to dwarf specs [v2-v5], DW_AT_address_class only applies to pointer or reference types, subroutines or subroutine types. 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+.



https://reviews.llvm.org/D29670





More information about the llvm-commits mailing list