From 338ef7a82c720b73faf64b31605aa2709b0cf14a Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Wed, 9 Nov 2016 00:42:03 +0000 Subject: Emit debug info for global constants whose address is taken exactly once. Add a check to the DeclCache before emitting debug info for a GlobalVariable a second time and just attach the previsously created one to it. llvm-svn: 286322 --- clang/lib/CodeGen/CGDebugInfo.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp') diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index b17d2482a78..c4e7ffdd54e 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -3675,6 +3675,13 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var, assert(DebugKind >= codegenoptions::LimitedDebugInfo); if (D->hasAttr()) return; + + // If we already created a DIGlobalVariable for this declaration, just attach + // it to the llvm::GlobalVariable. + auto Cached = DeclCache.find(D->getCanonicalDecl()); + if (Cached != DeclCache.end()) + return Var->addDebugInfo(cast(Cached->second)); + // Create global variable debug descriptor. llvm::DIFile *Unit = nullptr; llvm::DIScope *DContext = nullptr; -- cgit v1.2.3