On Fri, Sep 18, 2015 at 4:01 PM, Adrian Prantl via cfe-commits < cfe-commits@lists.llvm.org> wrote:
> Author: adrian > Date: Fri Sep 18 18:01:45 2015 > New Revision: 248062 > > URL: http://llvm.org/viewvc/llvm-project?rev=248062&view=rev > Log: > 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. > > 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=248062&r1=248061&r2=248062&view=diff > > ============================================================================== > --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 18 18:01:45 2015 > @@ -1673,7 +1673,8 @@ llvm::DIType *CGDebugInfo::CreateType(co > } > > llvm::DIModule * > -CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor > Mod) { > +CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor > Mod, > + bool CreateSkeletonCU) { > auto &ModRef = ModuleRefCache[Mod.ModuleName]; > if (ModRef) > return cast<llvm::DIModule>(ModRef); > @@ -1700,15 +1701,20 @@ CGDebugInfo::getOrCreateModuleRef(Extern > 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); > Could you remind me why we have a module in the skeleton CU? > + 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::getParentMo > 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 I > auto *Reader = CGM.getContext().getExternalSource(); > auto Info = Reader->getSourceDescriptor(*ID.getImportedModule()); > DBuilder.createImportedDeclaration( > - getCurrentContextDescriptor(cast<Decl>(ID.getDeclContext())), > - getOrCreateModuleRef(Info), > - getLineNumber(ID.getLocation())); > + getCurrentContextDescriptor(cast<Decl>(ID.getDeclContext())), > + getOrCreateModuleRef(Info, DebugTypeExtRefs), > + getLineNumber(ID.getLocation())); > } > > llvm::DIImportedEntity * > > Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=248062&r1=248061&r2=248062&view=diff > > ============================================================================== > --- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original) > +++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Fri Sep 18 18:01:45 2015 > @@ -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); > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits