summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp26
-rw-r--r--lib/IR/DIBuilder.cpp1
-rw-r--r--lib/IR/DebugInfo.cpp6
-rw-r--r--test/CodeGen/ARM/debug-info-blocks.ll10
4 files changed, 27 insertions, 16 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 0c9bc23a9e..2937b9019c 100644
--- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -776,8 +776,7 @@ DIE *CompileUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
/// addType - Add a new type attribute to the specified entity.
void CompileUnit::addType(DIE *Entity, DIType Ty, uint16_t Attribute) {
- if (!Ty.isType())
- return;
+ assert(Ty && "Trying to add a type that doesn't exist?");
// Check for pre-existence.
DIEEntry *Entry = getDIEEntry(Ty);
@@ -863,7 +862,8 @@ void CompileUnit::constructTypeDIE(DIE &Buffer, DIDerivedType DTy) {
// Map to main type, void will not have a type.
DIType FromTy = DTy.getTypeDerivedFrom();
- addType(&Buffer, FromTy);
+ if (FromTy)
+ addType(&Buffer, FromTy);
// Add name if not anonymous or intermediate type.
if (!Name.empty())
@@ -947,10 +947,11 @@ void CompileUnit::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
}
break;
case dwarf::DW_TAG_subroutine_type: {
- // Add return type.
+ // Add return type. A void return won't have a type.
DIArray Elements = CTy.getTypeArray();
DIDescriptor RTy = Elements.getElement(0);
- addType(&Buffer, DIType(RTy));
+ if (RTy)
+ addType(&Buffer, DIType(RTy));
bool isPrototyped = true;
// Add arguments.
@@ -1137,7 +1138,11 @@ CompileUnit::getOrCreateTemplateValueParameterDIE(DITemplateValueParameter VP) {
return ParamDIE;
ParamDIE = new DIE(VP.getTag());
- addType(ParamDIE, VP.getType());
+
+ // Add the type if there is one, template template and template parameter
+ // packs will not have a type.
+ if (VP.getType())
+ addType(ParamDIE, VP.getType());
if (!VP.getName().empty())
addString(ParamDIE, dwarf::DW_AT_name, VP.getName());
if (Value *Val = VP.getValue()) {
@@ -1246,13 +1251,14 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
Language == dwarf::DW_LANG_ObjC))
addFlag(SPDie, dwarf::DW_AT_prototyped);
- // Add Return Type.
+ // Add Return Type. A void return type will not have a type.
DICompositeType SPTy = SP.getType();
assert(SPTy.getTag() == dwarf::DW_TAG_subroutine_type &&
"the type of a subprogram should be a subroutine");
DIArray Args = SPTy.getTypeArray();
- addType(SPDie, DIType(Args.getElement(0)));
+ if (Args.getElement(0))
+ addType(SPDie, DIType(Args.getElement(0)));
unsigned VK = SP.getVirtuality();
if (VK) {
@@ -1502,9 +1508,8 @@ void CompileUnit::constructArrayTypeDIE(DIE &Buffer,
if (CTy->isVector())
addFlag(&Buffer, dwarf::DW_AT_GNU_vector);
- // Emit derived type.
+ // Emit the element type.
addType(&Buffer, CTy->getTypeDerivedFrom());
- DIArray Elements = CTy->getTypeArray();
// Get an anonymous type for index type.
// FIXME: This type should be passed down from the front end
@@ -1522,6 +1527,7 @@ void CompileUnit::constructArrayTypeDIE(DIE &Buffer,
}
// Add subranges to array type.
+ DIArray Elements = CTy->getTypeArray();
for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
DIDescriptor Element = Elements.getElement(i);
if (Element.getTag() == dwarf::DW_TAG_subrange_type)
diff --git a/lib/IR/DIBuilder.cpp b/lib/IR/DIBuilder.cpp
index 3005f77742..e36d028899 100644
--- a/lib/IR/DIBuilder.cpp
+++ b/lib/IR/DIBuilder.cpp
@@ -759,7 +759,6 @@ DICompositeType DIBuilder::createArrayType(uint64_t Size, uint64_t AlignInBits,
/// createVectorType - Create debugging information entry for a vector.
DICompositeType DIBuilder::createVectorType(uint64_t Size, uint64_t AlignInBits,
DIType Ty, DIArray Subscripts) {
-
// A vector is an array type with the FlagVector flag applied.
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_array_type),
diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp
index a6f1c3413e..fc9324949d 100644
--- a/lib/IR/DebugInfo.cpp
+++ b/lib/IR/DebugInfo.cpp
@@ -483,6 +483,12 @@ bool DICompositeType::Verify() const {
if (!fieldIsMDNode(DbgNode, 12))
return false;
+ // If this is an array type verify that we have a DIType in the derived type
+ // field as that's the type of our element.
+ if (getTag() == dwarf::DW_TAG_array_type)
+ if (!DIType(getTypeDerivedFrom()))
+ return false;
+
return DbgNode->getNumOperands() >= 10 && DbgNode->getNumOperands() <= 14;
}
diff --git a/test/CodeGen/ARM/debug-info-blocks.ll b/test/CodeGen/ARM/debug-info-blocks.ll
index bd55786876..8aa61cfe45 100644
--- a/test/CodeGen/ARM/debug-info-blocks.ll
+++ b/test/CodeGen/ARM/debug-info-blocks.ll
@@ -95,25 +95,25 @@ define hidden void @foobar_func_block_invoke_0(i8* %.block_descriptor, %0* %load
!llvm.dbg.cu = !{!0}
!0 = metadata !{i32 786449, metadata !153, i32 16, metadata !"Apple clang version 2.1", i1 false, metadata !"", i32 2, metadata !147, metadata !26, metadata !148, null, null, metadata !""} ; [ DW_TAG_compile_unit ]
-!1 = metadata !{i32 786433, metadata !160, metadata !0, metadata !"", i32 248, i64 32, i64 32, i32 0, i32 0, i32 0, metadata !3, i32 0, i32 0} ; [ DW_TAG_enumeration_type ]
+!1 = metadata !{i32 786436, metadata !160, metadata !0, metadata !"", i32 248, i64 32, i64 32, i32 0, i32 0, i32 0, metadata !3, i32 0, i32 0} ; [ DW_TAG_enumeration_type ]
!2 = metadata !{i32 786473, metadata !160} ; [ DW_TAG_file_type ]
!3 = metadata !{metadata !4}
!4 = metadata !{i32 786472, metadata !"Ver1", i64 0} ; [ DW_TAG_enumerator ]
-!5 = metadata !{i32 786433, metadata !160, metadata !0, metadata !"Mode", i32 79, i64 32, i64 32, i32 0, i32 0, i32 0, metadata !7, i32 0, i32 0} ; [ DW_TAG_enumeration_type ]
+!5 = metadata !{i32 786436, metadata !160, metadata !0, metadata !"Mode", i32 79, i64 32, i64 32, i32 0, i32 0, i32 0, metadata !7, i32 0, i32 0} ; [ DW_TAG_enumeration_type ]
!6 = metadata !{i32 786473, metadata !161} ; [ DW_TAG_file_type ]
!7 = metadata !{metadata !8}
!8 = metadata !{i32 786472, metadata !"One", i64 0} ; [ DW_TAG_enumerator ]
-!9 = metadata !{i32 786433, metadata !149, metadata !0, metadata !"", i32 15, i64 32, i64 32, i32 0, i32 0, i32 0, metadata !11, i32 0, i32 0} ; [ DW_TAG_enumeration_type ]
+!9 = metadata !{i32 786436, metadata !149, metadata !0, metadata !"", i32 15, i64 32, i64 32, i32 0, i32 0, i32 0, metadata !11, i32 0, i32 0} ; [ DW_TAG_enumeration_type ]
!10 = metadata !{i32 786473, metadata !149} ; [ DW_TAG_file_type ]
!11 = metadata !{metadata !12, metadata !13}
!12 = metadata !{i32 786472, metadata !"Unknown", i64 0} ; [ DW_TAG_enumerator ]
!13 = metadata !{i32 786472, metadata !"Known", i64 1} ; [ DW_TAG_enumerator ]
-!14 = metadata !{i32 786433, metadata !150, metadata !0, metadata !"", i32 20, i64 32, i64 32, i32 0, i32 0, i32 0, metadata !16, i32 0, i32 0} ; [ DW_TAG_enumeration_type ]
+!14 = metadata !{i32 786436, metadata !150, metadata !0, metadata !"", i32 20, i64 32, i64 32, i32 0, i32 0, i32 0, metadata !16, i32 0, i32 0} ; [ DW_TAG_enumeration_type ]
!15 = metadata !{i32 786473, metadata !150} ; [ DW_TAG_file_type ]
!16 = metadata !{metadata !17, metadata !18}
!17 = metadata !{i32 786472, metadata !"Single", i64 0} ; [ DW_TAG_enumerator ]
!18 = metadata !{i32 786472, metadata !"Double", i64 1} ; [ DW_TAG_enumerator ]
-!19 = metadata !{i32 786433, metadata !151, metadata !0, metadata !"", i32 14, i64 32, i64 32, i32 0, i32 0, i32 0, metadata !21, i32 0, i32 0} ; [ DW_TAG_enumeration_type ]
+!19 = metadata !{i32 786436, metadata !151, metadata !0, metadata !"", i32 14, i64 32, i64 32, i32 0, i32 0, i32 0, metadata !21, i32 0, i32 0} ; [ DW_TAG_enumeration_type ]
!20 = metadata !{i32 786473, metadata !151} ; [ DW_TAG_file_type ]
!21 = metadata !{metadata !22}
!22 = metadata !{i32 786472, metadata !"Eleven", i64 0} ; [ DW_TAG_enumerator ]