r188474 - DebugInfo: Don't create duplicate forward declaration metadata unnecessarily.
David Blaikie
dblaikie at gmail.com
Thu Aug 15 11:59:41 PDT 2013
Author: dblaikie
Date: Thu Aug 15 13:59:40 2013
New Revision: 188474
URL: http://llvm.org/viewvc/llvm-project?rev=188474&view=rev
Log:
DebugInfo: Don't create duplicate forward declaration metadata unnecessarily.
No functionality change, at best a slight (questionable) optimization,
but necessary for correctness of future work.
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=188474&r1=188473&r2=188474&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Aug 15 13:59:40 2013
@@ -602,8 +602,12 @@ llvm::DIType CGDebugInfo::CreateType(con
}
// Creates a forward declaration for a RecordDecl in the given context.
-llvm::DIType CGDebugInfo::createRecordFwdDecl(const RecordDecl *RD,
- llvm::DIDescriptor Ctx) {
+llvm::DICompositeType
+CGDebugInfo::getOrCreateRecordFwdDecl(const RecordDecl *RD,
+ llvm::DIDescriptor Ctx) {
+ llvm::DICompositeType T(getTypeOrNull(CGM.getContext().getRecordType(RD)));
+ if (T)
+ return T;
llvm::DIFile DefUnit = getOrCreateFile(RD->getLocation());
unsigned Line = getLineNumber(RD->getLocation());
StringRef RDName = getClassName(RD);
@@ -1413,7 +1417,7 @@ llvm::DIType CGDebugInfo::CreateType(con
// test/CodeGen/debug-info-records.c .
llvm::DIDescriptor FDContext =
getContextDescriptor(cast<Decl>(RD->getDeclContext()));
- llvm::DIType RetTy = createRecordFwdDecl(RD, FDContext);
+ llvm::DIType RetTy = getOrCreateRecordFwdDecl(RD, FDContext);
TypeCache[QualType(Ty, 0).getAsOpaquePtr()] = RetTy;
return RetTy;
}
@@ -2175,7 +2179,7 @@ llvm::DIType CGDebugInfo::CreateLimitedT
// If this is just a forward declaration, construct an appropriately
// marked node and just return it.
if (!RD->getDefinition())
- return createRecordFwdDecl(RD, RDContext);
+ return getOrCreateRecordFwdDecl(RD, RDContext);
uint64_t Size = CGM.getContext().getTypeSize(Ty);
uint64_t Align = CGM.getContext().getTypeAlign(Ty);
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=188474&r1=188473&r2=188474&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Aug 15 13:59:40 2013
@@ -305,9 +305,9 @@ private:
llvm::DIScope getCurrentContextDescriptor(const Decl *Decl);
- /// createRecordFwdDecl - Create a forward decl for a RecordType in a given
- /// context.
- llvm::DIType createRecordFwdDecl(const RecordDecl *, llvm::DIDescriptor);
+ /// \brief Create a forward decl for a RecordType in a given context.
+ llvm::DICompositeType getOrCreateRecordFwdDecl(const RecordDecl *,
+ llvm::DIDescriptor);
/// createContextChain - Create a set of decls for the context chain.
llvm::DIDescriptor createContextChain(const Decl *Decl);
More information about the cfe-commits
mailing list