diff options
author | David Blaikie <dblaikie@gmail.com> | 2013-08-15 18:59:40 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2013-08-15 18:59:40 +0000 |
commit | d816e2d3b00e18fd28dbbdc2a748b1ec88330911 (patch) | |
tree | 837c9f8374a72a046c4405c2bf879e95fbe3a71e /clang/lib/CodeGen/CGDebugInfo.cpp | |
parent | 0b48e7c6bd8368232322ab484708577483a54996 (diff) | |
download | bcm5719-llvm-d816e2d3b00e18fd28dbbdc2a748b1ec88330911.tar.gz bcm5719-llvm-d816e2d3b00e18fd28dbbdc2a748b1ec88330911.zip |
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.
llvm-svn: 188474
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 1d3bad9f6dd..8eb89871c55 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -602,8 +602,12 @@ llvm::DIType CGDebugInfo::CreateType(const PointerType *Ty, } // 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(const RecordType *Ty, bool Declaration) { // 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::CreateLimitedType(const RecordType *Ty) { // 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); |