summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2013-08-15 20:49:17 +0000
committerDavid Blaikie <dblaikie@gmail.com>2013-08-15 20:49:17 +0000
commitb2e86eb64acdca438466d9423a3a6e635e71e078 (patch)
treeb44e7cff5bdd01231ac1a35bb826cebfbdabcc16 /clang/lib/CodeGen/CGDebugInfo.cpp
parent0a41d9ae7f0b70c5a613f72f119fa1c30fd6353a (diff)
downloadbcm5719-llvm-b2e86eb64acdca438466d9423a3a6e635e71e078.tar.gz
bcm5719-llvm-b2e86eb64acdca438466d9423a3a6e635e71e078.zip
DebugInfo: Unify & optimize the lazy addition of record types
Rather than going through the whole getOrCreateType machinery to manifest a type, cut straight to the implementation because we know we have to do work. While the previous implementation was sufficient for the two cases (completeness and required completeness) we have already (the general machinery could inspect the type for those attributes & go down the full definition path), a pending change (to emit info for types when we emit their vtables) won't have that luxury & we'll need to force the creation rather than relying on the general purpose routine. llvm-svn: 188486
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp40
1 files changed, 26 insertions, 14 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 5ac4a5dccbf..94f1bde38d5 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1403,6 +1403,26 @@ llvm::DIType CGDebugInfo::getOrCreateInterfaceType(QualType D,
return T;
}
+void CGDebugInfo::completeType(const RecordDecl *RD) {
+ if (DebugKind > CodeGenOptions::LimitedDebugInfo ||
+ !CGM.getLangOpts().CPlusPlus)
+ completeRequiredType(RD);
+}
+
+void CGDebugInfo::completeRequiredType(const RecordDecl *RD) {
+ QualType Ty = CGM.getContext().getRecordType(RD);
+ llvm::DIType T = getTypeOrNull(Ty);
+ if (!T || !T.isForwardDecl())
+ return;
+ void* TyPtr = Ty.getAsOpaquePtr();
+ if (CompletedTypeCache.count(TyPtr))
+ return;
+ llvm::DIType Res = CreateTypeDefinition(Ty->castAs<RecordType>());
+ assert(!Res.isForwardDecl());
+ CompletedTypeCache[TyPtr] = Res;
+ TypeCache[TyPtr] = Res;
+}
+
/// CreateType - get structure or union type.
llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty, bool Declaration) {
RecordDecl *RD = Ty->getDecl();
@@ -1419,6 +1439,12 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty, bool Declaration) {
return RetTy;
}
+ return CreateTypeDefinition(Ty);
+}
+
+llvm::DIType CGDebugInfo::CreateTypeDefinition(const RecordType *Ty) {
+ RecordDecl *RD = Ty->getDecl();
+
// Get overall information about the record type for the debug info.
llvm::DIFile DefUnit = getOrCreateFile(RD->getLocation());
@@ -1930,20 +1956,6 @@ llvm::DIType CGDebugInfo::getCompletedTypeOrNull(QualType Ty) {
return llvm::DIType(cast_or_null<llvm::MDNode>(V));
}
-void CGDebugInfo::completeFwdDecl(const RecordDecl &RD) {
- // In limited debug info we only want to do this if the complete type was
- // required.
- if (DebugKind <= CodeGenOptions::LimitedDebugInfo &&
- CGM.getLangOpts().CPlusPlus)
- return;
-
- QualType QTy = CGM.getContext().getRecordType(&RD);
- llvm::DIType T = getTypeOrNull(QTy);
-
- if (T && T.isForwardDecl())
- getOrCreateType(QTy, getOrCreateFile(RD.getLocation()));
-}
-
/// getCachedInterfaceTypeOrNull - Get the type from the interface
/// cache, unless it needs to regenerated. Otherwise return null.
llvm::Value *CGDebugInfo::getCachedInterfaceTypeOrNull(QualType Ty) {
OpenPOWER on IntegriCloud