summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorEric Christopher <echristo@apple.com>2011-12-16 23:40:18 +0000
committerEric Christopher <echristo@apple.com>2011-12-16 23:40:18 +0000
commitcd88813dbfbb9d3e57803d17f702e65af94979e4 (patch)
tree101d8fa528370bae7692ee3a8e85bf44877ba308 /clang/lib
parentea225fb41269eb0a8c6bcb1f7778d23a8881c526 (diff)
downloadbcm5719-llvm-cd88813dbfbb9d3e57803d17f702e65af94979e4.tar.gz
bcm5719-llvm-cd88813dbfbb9d3e57803d17f702e65af94979e4.zip
When in a limited debug information situation if we can find the original
declaration for the type then go ahead and use that, it's still smaller than creating an all new derived type. Part of rdar://10335756 and others. llvm-svn: 146779
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp29
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.h1
2 files changed, 24 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index dd76640ba3d..af6d25d363a 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -488,6 +488,11 @@ llvm::DIType CGDebugInfo::CreatePointeeType(QualType PointeeTy,
// Limit debug info for the pointee type.
+ // If we have an existing type, use that, it's still smaller than creating
+ // a new type.
+ llvm::DIType Ty = getTypeOrNull(PointeeTy);
+ if (Ty.Verify()) return Ty;
+
// Handle qualifiers.
if (PointeeTy.hasLocalQualifiers())
return CreateQualifiedType(PointeeTy, Unit);
@@ -1565,15 +1570,12 @@ static QualType UnwrapTypeForDebugInfo(QualType T) {
return T;
}
-/// getOrCreateType - Get the type from the cache or create a new
-/// one if necessary.
-llvm::DIType CGDebugInfo::getOrCreateType(QualType Ty, llvm::DIFile Unit) {
- if (Ty.isNull())
- return llvm::DIType();
+/// getType - Get the type from the cache or return null type if it doesn't exist.
+llvm::DIType CGDebugInfo::getTypeOrNull(QualType Ty) {
// Unwrap the type as needed for debug information.
Ty = UnwrapTypeForDebugInfo(Ty);
-
+
// Check for existing entry.
llvm::DenseMap<void *, llvm::WeakVH>::iterator it =
TypeCache.find(Ty.getAsOpaquePtr());
@@ -1583,6 +1585,21 @@ llvm::DIType CGDebugInfo::getOrCreateType(QualType Ty, llvm::DIFile Unit) {
return llvm::DIType(cast<llvm::MDNode>(it->second));
}
+ return llvm::DIType();
+}
+
+/// getOrCreateType - Get the type from the cache or create a new
+/// one if necessary.
+llvm::DIType CGDebugInfo::getOrCreateType(QualType Ty, llvm::DIFile Unit) {
+ if (Ty.isNull())
+ return llvm::DIType();
+
+ // Unwrap the type as needed for debug information.
+ Ty = UnwrapTypeForDebugInfo(Ty);
+
+ llvm::DIType T = getTypeOrNull(Ty);
+ if (T.Verify()) return T;
+
// Otherwise create the type.
llvm::DIType Res = CreateTypeNode(Ty, Unit);
diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index 087cdd08a49..8831c535fa4 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -93,6 +93,7 @@ class CGDebugInfo {
llvm::DIType CreateType(const MemberPointerType *Ty, llvm::DIFile F);
llvm::DIType CreateType(const AtomicType *Ty, llvm::DIFile F);
llvm::DIType CreateEnumType(const EnumDecl *ED);
+ llvm::DIType getTypeOrNull(const QualType);
llvm::DIType getOrCreateMethodType(const CXXMethodDecl *Method,
llvm::DIFile F);
llvm::DIType getOrCreateFunctionType(const Decl *D, QualType FnType,
OpenPOWER on IntegriCloud