summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
diff options
context:
space:
mode:
authorMomchil Velikov <momchil.velikov@arm.com>2018-02-07 16:46:33 +0000
committerMomchil Velikov <momchil.velikov@arm.com>2018-02-07 16:46:33 +0000
commitc502027efdf0361d5f8f57af6ad62d8096f0b6da (patch)
tree129c60d419acb0de03aa68b89df1e9d166646a9e /llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
parent466396592d7a5440379b0e606e7e8674c6d348fd (diff)
downloadbcm5719-llvm-c502027efdf0361d5f8f57af6ad62d8096f0b6da.tar.gz
bcm5719-llvm-c502027efdf0361d5f8f57af6ad62d8096f0b6da.zip
[DebugInfo] Improvements to representation of enumeration types (PR36168)
This patch is the LLVM part of fixing the issues, described in https://bugs.llvm.org/show_bug.cgi?id=36168 * The representation of enumerator values in the debug info metadata now contains a boolean flag isUnsigned, which determines how the bits of the value are interpreted. * The DW_TAG_enumeration type DIE now always (for DWARF version >= 3) includes a DW_AT_type attribute, which refers to the underlying integer type, as suggested in DWARFv4 (5.7 Enumeration Type Entries). * The debug info metadata for enumeration type contains (in flags) indication whether this is a C++11 "fixed enum". * For C++11 enumeration with a fixed underlying type, the DIE also includes the DW_AT_enum_class attribute (for DWARF version >= 4). * Encoding of enumerator constants uses DW_FORM_sdata for signed values and DW_FORM_udata for unsigned values, as suggested by DWARFv4 (7.5.4 Attribute Encodings). The changes should be backwards compatible: * the isUnsigned attribute is optional and defaults to false. * if the underlying type for the enumeration is not available, the enumerator values are considered signed. * the FixedEnum flag defaults to clear. * the bitcode format for DIEnumerator stores the unsigned flag bit #1 of the first record element, so the format does not change and the zero previously stored there is consistent with the false default for IsUnsigned. Differential Revision: https://reviews.llvm.org/D42734 llvm-svn: 324489
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index 0e6ed1c349f..939d13faec0 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1427,6 +1427,15 @@ void DwarfUnit::constructArrayTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
}
void DwarfUnit::constructEnumTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
+ const DIType *DTy = resolve(CTy->getBaseType());
+ bool IsUnsigned = DTy && isUnsignedDIType(DD, DTy);
+ if (DTy && DD->getDwarfVersion() >= 3)
+ addType(Buffer, DTy);
+ if (DD->getDwarfVersion() >= 4 && (CTy->getFlags() & DINode::FlagFixedEnum)) {
+ assert(DTy);
+ addFlag(Buffer, dwarf::DW_AT_enum_class);
+ }
+
DINodeArray Elements = CTy->getElements();
// Add enumerators to enumeration type.
@@ -1436,16 +1445,10 @@ void DwarfUnit::constructEnumTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
DIE &Enumerator = createAndAddDIE(dwarf::DW_TAG_enumerator, Buffer);
StringRef Name = Enum->getName();
addString(Enumerator, dwarf::DW_AT_name, Name);
- int64_t Value = Enum->getValue();
- addSInt(Enumerator, dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata,
- Value);
+ auto Value = static_cast<uint64_t>(Enum->getValue());
+ addConstantValue(Enumerator, IsUnsigned, Value);
}
}
- const DIType *DTy = resolve(CTy->getBaseType());
- if (DTy) {
- addType(Buffer, DTy);
- addFlag(Buffer, dwarf::DW_AT_enum_class);
- }
}
void DwarfUnit::constructContainingTypeDIEs() {
OpenPOWER on IntegriCloud