summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/DebugInfo.h34
-rw-r--r--llvm/lib/IR/DIBuilder.cpp14
-rw-r--r--llvm/lib/IR/DebugInfo.cpp11
3 files changed, 32 insertions, 27 deletions
diff --git a/llvm/include/llvm/DebugInfo.h b/llvm/include/llvm/DebugInfo.h
index bbb274329cb..4d08ce90b28 100644
--- a/llvm/include/llvm/DebugInfo.h
+++ b/llvm/include/llvm/DebugInfo.h
@@ -155,20 +155,6 @@ namespace llvm {
template <>
DITypeRef DIDescriptor::getFieldAs<DITypeRef>(unsigned Elt) const;
- /// Represents reference to a DIType, abstracts over direct and
- /// identifier-based metadata type references.
- class DITypeRef {
- template <typename DescTy>
- friend DescTy DIDescriptor::getFieldAs(unsigned Elt) const;
-
- /// TypeVal can be either a MDNode or a MDString, in the latter,
- /// MDString specifies the type identifier.
- const Value *TypeVal;
- explicit DITypeRef(const Value *V);
- public:
- DIType resolve(const DITypeIdentifierMap &Map) const;
- };
-
/// DISubrange - This is used to represent ranges, for array bounds.
class DISubrange : public DIDescriptor {
friend class DIDescriptor;
@@ -285,12 +271,32 @@ namespace llvm {
/// isUnsignedDIType - Return true if type encoding is unsigned.
bool isUnsignedDIType();
+ /// Generate a reference to this DIType. Uses the type identifier instead
+ /// of the actual MDNode if possible, to help type uniquing.
+ DITypeRef generateRef();
+
/// replaceAllUsesWith - Replace all uses of debug info referenced by
/// this descriptor.
void replaceAllUsesWith(DIDescriptor &D);
void replaceAllUsesWith(MDNode *D);
};
+ /// Represents reference to a DIType, abstracts over direct and
+ /// identifier-based metadata type references.
+ class DITypeRef {
+ template <typename DescTy>
+ friend DescTy DIDescriptor::getFieldAs(unsigned Elt) const;
+ friend DITypeRef DIType::generateRef();
+
+ /// TypeVal can be either a MDNode or a MDString, in the latter,
+ /// MDString specifies the type identifier.
+ const Value *TypeVal;
+ explicit DITypeRef(const Value *V);
+ public:
+ DIType resolve(const DITypeIdentifierMap &Map) const;
+ operator Value *() const { return const_cast<Value*>(TypeVal); }
+ };
+
/// DIBasicType - A basic type, like 'int' or 'float'.
class DIBasicType : public DIType {
public:
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index 2ff10b593ed..d58a9dcd7a9 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -75,18 +75,6 @@ void DIBuilder::finalize() {
DIType(TempImportedModules).replaceAllUsesWith(IMs);
}
-/// Use the type identifier instead of the actual MDNode if possible,
-/// to help type uniquing. This function returns the identifier if it
-/// exists for the given type, otherwise returns the MDNode.
-static Value *getTypeIdentifier(DIType T) {
- if (!T.isCompositeType())
- return T;
- DICompositeType DTy(T);
- if (!DTy.getIdentifier())
- return T;
- return DTy.getIdentifier();
-}
-
/// getNonCompileUnitScope - If N is compile unit return NULL otherwise return
/// N.
static MDNode *getNonCompileUnitScope(MDNode *N) {
@@ -334,7 +322,7 @@ DIDerivedType DIBuilder::createMemberPointerType(DIType PointeeTy,
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Offset
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
PointeeTy,
- getTypeIdentifier(Base)
+ Base.generateRef()
};
return DIDerivedType(MDNode::get(VMContext, Elts));
}
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index d3207cae350..70b4257caeb 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -707,6 +707,17 @@ void DICompositeType::addMember(DIDescriptor D) {
setTypeArray(DIArray(MDNode::get(DbgNode->getContext(), M)));
}
+/// Generate a reference to this DIType. Uses the type identifier instead
+/// of the actual MDNode if possible, to help type uniquing.
+DITypeRef DIType::generateRef() {
+ if (!isCompositeType())
+ return DITypeRef(*this);
+ DICompositeType DTy(DbgNode);
+ if (!DTy.getIdentifier())
+ return DITypeRef(*this);
+ return DITypeRef(DTy.getIdentifier());
+}
+
/// \brief Set the containing type.
void DICompositeType::setContainingType(DICompositeType ContainingType) {
TrackingVH<MDNode> N(*this);
OpenPOWER on IntegriCloud