aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Analysis/DebugInfo.h6
-rw-r--r--lib/Analysis/DebugInfo.cpp10
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp22
3 files changed, 32 insertions, 6 deletions
diff --git a/include/llvm/Analysis/DebugInfo.h b/include/llvm/Analysis/DebugInfo.h
index 51bede0..2d1418d 100644
--- a/include/llvm/Analysis/DebugInfo.h
+++ b/include/llvm/Analysis/DebugInfo.h
@@ -290,6 +290,9 @@ namespace llvm {
unsigned getEncoding() const { return getUnsignedField(9); }
+ /// Verify - Verify that a basic type descriptor is well formed.
+ bool Verify() const;
+
/// print - print basic type.
void print(raw_ostream &OS) const;
@@ -313,6 +316,9 @@ namespace llvm {
/// return base type size.
uint64_t getOriginalTypeSize() const;
+ /// Verify - Verify that a derived type descriptor is well formed.
+ bool Verify() const;
+
/// print - print derived type.
void print(raw_ostream &OS) const;
diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp
index 0bd7904..c380028 100644
--- a/lib/Analysis/DebugInfo.cpp
+++ b/lib/Analysis/DebugInfo.cpp
@@ -303,6 +303,16 @@ bool DIType::Verify() const {
return true;
}
+/// Verify - Verify that a basic type descriptor is well formed.
+bool DIBasicType::Verify() const {
+ return isBasicType();
+}
+
+/// Verify - Verify that a derived type descriptor is well formed.
+bool DIDerivedType::Verify() const {
+ return isDerivedType();
+}
+
/// Verify - Verify that a composite type descriptor is well formed.
bool DICompositeType::Verify() const {
if (!DbgNode)
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index e236c1b..408549a 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -1861,6 +1861,21 @@ CompileUnit *DwarfDebug::getCompileUnit(const MDNode *N) const {
return I->second;
}
+/// isUnsignedDIType - Return true if type encoding is unsigned.
+static bool isUnsignedDIType(DIType Ty) {
+ DIDerivedType DTy(Ty);
+ if (DTy.Verify())
+ return isUnsignedDIType(DTy.getTypeDerivedFrom());
+
+ DIBasicType BTy(Ty);
+ if (BTy.Verify()) {
+ unsigned Encoding = BTy.getEncoding();
+ if (Encoding == dwarf::DW_ATE_unsigned ||
+ Encoding == dwarf::DW_ATE_unsigned_char)
+ return true;
+ }
+ return false;
+}
/// constructGlobalVariableDIE - Construct global variable DIE.
void DwarfDebug::constructGlobalVariableDIE(const MDNode *N) {
@@ -1930,17 +1945,12 @@ void DwarfDebug::constructGlobalVariableDIE(const MDNode *N) {
}
} else if (Constant *C = GV.getConstant()) {
if (ConstantInt *CI = dyn_cast<ConstantInt>(C)) {
- DIBasicType BTy(GTy);
- if (BTy.Verify()) {
- unsigned Encoding = BTy.getEncoding();
- if (Encoding == dwarf::DW_ATE_unsigned ||
- Encoding == dwarf::DW_ATE_unsigned_char)
+ if (isUnsignedDIType(GTy))
addUInt(VariableDIE, dwarf::DW_AT_const_value, dwarf::DW_FORM_udata,
CI->getZExtValue());
else
addSInt(VariableDIE, dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata,
CI->getSExtValue());
- }
}
}
return;