From c15da610ac7f74bbac57c8b14388cd7684e5ed5a Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Fri, 18 Sep 2015 23:01:45 +0000 Subject: [PATCH] CGDebugInfo: Make creating a skeleton CU in getOrCreateModuleRef optional. We don't want a skeleton CU when generating debug info for the module itself. NFC. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248062 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDebugInfo.cpp | 35 +++++++++++++++++++++-------------- lib/CodeGen/CGDebugInfo.h | 6 ++++-- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 0b44e93c5c..723e8ffde3 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -1673,7 +1673,8 @@ llvm::DIType *CGDebugInfo::CreateType(const ObjCInterfaceType *Ty, } llvm::DIModule * -CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod) { +CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod, + bool CreateSkeletonCU) { auto &ModRef = ModuleRefCache[Mod.ModuleName]; if (ModRef) return cast(ModRef); @@ -1700,15 +1701,20 @@ CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod) { OS << '\"'; } } - llvm::DIBuilder DIB(CGM.getModule()); - auto *CU = DIB.createCompileUnit(TheCU->getSourceLanguage(), Mod.ModuleName, - Mod.Path, TheCU->getProducer(), true, - StringRef(), 0, Mod.ASTFile, - llvm::DIBuilder::FullDebug, Mod.Signature); - llvm::DIModule *M = - DIB.createModule(CU, Mod.ModuleName, ConfigMacros, Mod.Path, - CGM.getHeaderSearchOpts().Sysroot); - DIB.finalize(); + + llvm::DIModule *M = nullptr; + if (CreateSkeletonCU) { + llvm::DIBuilder DIB(CGM.getModule()); + auto *CU = DIB.createCompileUnit(TheCU->getSourceLanguage(), Mod.ModuleName, + Mod.Path, TheCU->getProducer(), true, + StringRef(), 0, Mod.ASTFile, + llvm::DIBuilder::FullDebug, Mod.Signature); + M = DIB.createModule(CU, Mod.ModuleName, ConfigMacros, Mod.Path, + CGM.getHeaderSearchOpts().Sysroot); + DIB.finalize(); + } else + M = DBuilder.createModule(TheCU, Mod.ModuleName, ConfigMacros, Mod.Path, + CGM.getHeaderSearchOpts().Sysroot); ModRef.reset(M); return M; } @@ -2158,12 +2164,13 @@ llvm::DIModule *CGDebugInfo::getParentModuleOrNull(const Decl *D) { if (!DebugTypeExtRefs || !D->isFromASTFile()) return nullptr; + // Record a reference to an imported clang module or precompiled header. llvm::DIModule *ModuleRef = nullptr; auto *Reader = CGM.getContext().getExternalSource(); auto Idx = D->getOwningModuleID(); auto Info = Reader->getSourceDescriptor(Idx); if (Info) - ModuleRef = getOrCreateModuleRef(*Info); + ModuleRef = getOrCreateModuleRef(*Info, true); return ModuleRef; } @@ -3387,9 +3394,9 @@ void CGDebugInfo::EmitImportDecl(const ImportDecl &ID) { auto *Reader = CGM.getContext().getExternalSource(); auto Info = Reader->getSourceDescriptor(*ID.getImportedModule()); DBuilder.createImportedDeclaration( - getCurrentContextDescriptor(cast(ID.getDeclContext())), - getOrCreateModuleRef(Info), - getLineNumber(ID.getLocation())); + getCurrentContextDescriptor(cast(ID.getDeclContext())), + getOrCreateModuleRef(Info, DebugTypeExtRefs), + getLineNumber(ID.getLocation())); } llvm::DIImportedEntity * diff --git a/lib/CodeGen/CGDebugInfo.h b/lib/CodeGen/CGDebugInfo.h index 72c6779178..8d42f57a3e 100644 --- a/lib/CodeGen/CGDebugInfo.h +++ b/lib/CodeGen/CGDebugInfo.h @@ -403,9 +403,11 @@ private: /// Get the type from the cache or create a new type if necessary. llvm::DIType *getOrCreateType(QualType Ty, llvm::DIFile *Fg); - /// Get a reference to a clang module. + /// Get a reference to a clang module. If \p CreateSkeletonCU is true, + /// this also creates a split dwarf skeleton compile unit. llvm::DIModule * - getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod); + getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod, + bool CreateSkeletonCU); /// DebugTypeExtRefs: If \p D originated in a clang module, return it. llvm::DIModule *getParentModuleOrNull(const Decl *D); -- 2.40.0