summaryrefslogtreecommitdiff
path: root/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-05-20 18:21:51 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-05-20 18:21:51 +0000
commite2ab467b905b57be574e97bc529eddd0a4474633 (patch)
tree3b8bd22f3e17b0a64442571dd119fd2876a33749 /lib/CodeGen/AsmPrinter/DwarfUnit.cpp
parent5d7afdb2ec6121cf5a2bc97f01f0ebd4e39d7dde (diff)
downloadllvm-e2ab467b905b57be574e97bc529eddd0a4474633.tar.gz
llvm-e2ab467b905b57be574e97bc529eddd0a4474633.tar.bz2
llvm-e2ab467b905b57be574e97bc529eddd0a4474633.tar.xz
PR19767: DebugInfo emission of pointer constants.
In refactoring DwarfUnit::isUnsignedDIType I restricted it to only work on values with signedness (unsigned or signed), asserting on anything else (which did uncover some bugs). But it turns out that we do need to emit constants of signless data, such as pointer constants - only null pointer constants are known to need this so far, but it's conceivable that there might be non-null pointer constants at some point (hardcoded address offsets for device drivers?). This patch just uses 'unsigned' for signless data such as pointer constants. Arguably we could use signless representations (DW_FORM_dataN) instead, allowing a trinary result from isUnsignedDIType (signed, unsigned, signless), but this seems reasonable for now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209223 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfUnit.cpp')
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfUnit.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index 8adf78ca85..6b54173069 100644
--- a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -749,8 +749,19 @@ void DwarfUnit::addBlockByrefAddress(const DbgVariable &DV, DIE &Die,
static bool isUnsignedDIType(DwarfDebug *DD, DIType Ty) {
DIDerivedType DTy(Ty);
if (DTy.isDerivedType()) {
- if (DIType Deriv = DD->resolve(DTy.getTypeDerivedFrom()))
- return isUnsignedDIType(DD, Deriv);
+ dwarf::Tag T = (dwarf::Tag)Ty.getTag();
+ // Encode pointer constants as unsigned bytes. This is used at least for
+ // null pointer constant emission. Maybe DW_TAG_reference_type should be
+ // accepted here too, if there are ways to produce compile-time constant
+ // references.
+ if (T == dwarf::DW_TAG_pointer_type ||
+ T == dwarf::DW_TAG_ptr_to_member_type)
+ return true;
+ assert(T == dwarf::DW_TAG_typedef || T == dwarf::DW_TAG_const_type ||
+ T == dwarf::DW_TAG_volatile_type ||
+ T == dwarf::DW_TAG_restrict_type);
+ if (DITypeRef Deriv = DTy.getTypeDerivedFrom())
+ return isUnsignedDIType(DD, DD->resolve(Deriv));
// FIXME: Enums without a fixed underlying type have unknown signedness
// here, leading to incorrectly emitted constants.
assert(DTy.getTag() == dwarf::DW_TAG_enumeration_type);