summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2013-08-26 22:39:55 +0000
committerManman Ren <manman.ren@gmail.com>2013-08-26 22:39:55 +0000
commit0ed70aeb85cb0bf00721015afdebb4b825dc6fa1 (patch)
tree58fe46e21c20d39039981811be3002b613eba9ea /llvm/lib/IR
parentbdc9ff449800079c194d30e919ca74ce15f64284 (diff)
downloadbcm5719-llvm-0ed70aeb85cb0bf00721015afdebb4b825dc6fa1.tar.gz
bcm5719-llvm-0ed70aeb85cb0bf00721015afdebb4b825dc6fa1.zip
Debug Info: add an identifier field to DICompositeType.
DICompositeType will have an identifier field at position 14. For now, the field is set to null in DIBuilder. For DICompositeTypes where the template argument field (the 13th field) was optional, modify DIBuilder to make sure the template argument field is set. Now DICompositeType has 15 fields. Update DIBuilder to use NULL instead of "i32 0" for null value of a MDNode. Update verifier to check that DICompositeType has 15 fields and the last field is null or a MDString. Update testing cases to include an extra field for DICompositeType. The identifier field will be used by type uniquing so a front end can genearte a DICompositeType with a unique identifer. llvm-svn: 189282
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/DIBuilder.cpp29
-rw-r--r--llvm/lib/IR/DebugInfo.cpp18
2 files changed, 37 insertions, 10 deletions
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index 665e16ea8a7..7027813b814 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -617,7 +617,8 @@ DICompositeType DIBuilder::createClassType(DIDescriptor Context, StringRef Name,
Elements,
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
VTableHolder,
- TemplateParams
+ TemplateParams,
+ NULL // Type Identifer
};
DICompositeType R(MDNode::get(VMContext, Elts));
assert(R.isCompositeType() &&
@@ -651,6 +652,7 @@ DICompositeType DIBuilder::createStructType(DIDescriptor Context,
ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeLang),
VTableHolder,
NULL,
+ NULL // Type Identifer
};
DICompositeType R(MDNode::get(VMContext, Elts));
assert(R.isCompositeType() &&
@@ -679,8 +681,9 @@ DICompositeType DIBuilder::createUnionType(DIDescriptor Scope, StringRef Name,
NULL,
Elements,
ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeLang),
- Constant::getNullValue(Type::getInt32Ty(VMContext)),
- NULL
+ NULL,
+ NULL,
+ NULL // Type Identifer
};
return DICompositeType(MDNode::get(VMContext, Elts));
}
@@ -702,7 +705,9 @@ DIBuilder::createSubroutineType(DIFile File, DIArray ParameterTypes) {
NULL,
ParameterTypes,
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
- Constant::getNullValue(Type::getInt32Ty(VMContext))
+ NULL,
+ NULL,
+ NULL // Type Identifer
};
return DICompositeType(MDNode::get(VMContext, Elts));
}
@@ -727,7 +732,9 @@ DICompositeType DIBuilder::createEnumerationType(
UnderlyingType,
Elements,
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
- Constant::getNullValue(Type::getInt32Ty(VMContext))
+ NULL,
+ NULL,
+ NULL // Type Identifer
};
MDNode *Node = MDNode::get(VMContext, Elts);
AllEnumTypes.push_back(Node);
@@ -751,7 +758,9 @@ DICompositeType DIBuilder::createArrayType(uint64_t Size, uint64_t AlignInBits,
Ty,
Subscripts,
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
- Constant::getNullValue(Type::getInt32Ty(VMContext))
+ NULL,
+ NULL,
+ NULL // Type Identifer
};
return DICompositeType(MDNode::get(VMContext, Elts));
}
@@ -773,7 +782,9 @@ DICompositeType DIBuilder::createVectorType(uint64_t Size, uint64_t AlignInBits,
Ty,
Subscripts,
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
- Constant::getNullValue(Type::getInt32Ty(VMContext))
+ NULL,
+ NULL,
+ NULL // Type Identifer
};
return DICompositeType(MDNode::get(VMContext, Elts));
}
@@ -864,7 +875,9 @@ DICompositeType DIBuilder::createForwardDecl(unsigned Tag, StringRef Name,
NULL,
DIArray(),
ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang),
- NULL
+ NULL,
+ NULL, //TemplateParams
+ NULL // Type Identifer
};
MDNode *Node = MDNode::getTemporary(VMContext, Elts);
DICompositeType RetTy(Node);
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index fdd8d537ce4..8fad393e5ae 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -419,6 +419,12 @@ static bool fieldIsMDNode(const MDNode *DbgNode, unsigned Elt) {
return true;
}
+/// Check if a field at position Elt of a MDNode is a MDString.
+static bool fieldIsMDString(const MDNode *DbgNode, unsigned Elt) {
+ Value *Fld = getField(DbgNode, Elt);
+ return !Fld || isa<MDString>(Fld);
+}
+
/// Verify - Verify that a type descriptor is well formed.
bool DIType::Verify() const {
if (!isType())
@@ -483,13 +489,17 @@ bool DICompositeType::Verify() const {
if (!fieldIsMDNode(DbgNode, 12))
return false;
+ // Make sure the type identifier at field 14 is MDString, it can be null.
+ if (!fieldIsMDString(DbgNode, 14))
+ 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;
+ return DbgNode->getNumOperands() == 15;
}
/// Verify - Verify that a subprogram descriptor is well formed.
@@ -635,9 +645,13 @@ MDNode *DIDerivedType::getObjCProperty() const {
return getNodeField(DbgNode, 10);
}
+MDString *DICompositeType::getIdentifier() const {
+ return cast_or_null<MDString>(getField(DbgNode, 14));
+}
+
/// \brief Set the array of member DITypes.
void DICompositeType::setTypeArray(DIArray Elements, DIArray TParams) {
- assert((!TParams || DbgNode->getNumOperands() == 14) &&
+ assert((!TParams || DbgNode->getNumOperands() == 15) &&
"If you're setting the template parameters this should include a slot "
"for that!");
TrackingVH<MDNode> N(*this);
OpenPOWER on IntegriCloud