r246210 - CGDebugInfo: Factor out a getOrCreateStandaloneType() method.

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 27 14:25:29 PDT 2015


On Thu, Aug 27, 2015 at 2:21 PM, Adrian Prantl via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> Author: adrian
> Date: Thu Aug 27 16:21:19 2015
> New Revision: 246210
>
> URL: http://llvm.org/viewvc/llvm-project?rev=246210&view=rev
> Log:
> CGDebugInfo: Factor out a getOrCreateStandaloneType() method.
>
> Usually debug info is created on the fly while during codegen.
> With this API it becomes possible to create standalone debug info
> for types that are not referenced by any code, such as emitting debug info
> for a clang module or for implementing something like -gfull.
> Because on-the-fly debug info generation may still insert retained types
> on top of them, all RetainedTypes are uniqued in CGDebugInfo::finalize().
>

I don't quite understand why the new uniquing code is required - what is it
about this new codepath that necessitates that?


>
> 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=246210&r1=246209&r2=246210&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Aug 27 16:21:19 2015
> @@ -1398,8 +1398,15 @@ llvm::DIType *CGDebugInfo::getOrCreateRe
>
>  llvm::DIType *CGDebugInfo::getOrCreateInterfaceType(QualType D,
>                                                      SourceLocation Loc) {
> +  return getOrCreateStandaloneType(D, Loc);
> +}
> +
> +llvm::DIType *CGDebugInfo::getOrCreateStandaloneType(QualType D,
> +                                                     SourceLocation Loc) {
>    assert(DebugKind >= CodeGenOptions::LimitedDebugInfo);
> +  assert(!D.isNull() && "null type");
>    llvm::DIType *T = getOrCreateType(D, getOrCreateFile(Loc));
> +  assert(T && "could not create debug info for type");
>    RetainedTypes.push_back(D.getAsOpaquePtr());
>    return T;
>  }
> @@ -3360,9 +3367,14 @@ void CGDebugInfo::finalize() {
>
>    // We keep our own list of retained types, because we need to look
>    // up the final type in the type cache.
> -  for (std::vector<void *>::const_iterator RI = RetainedTypes.begin(),
> -         RE = RetainedTypes.end(); RI != RE; ++RI)
> -    DBuilder.retainType(cast<llvm::DIType>(TypeCache[*RI]));
> +  llvm::DenseSet<void *> UniqueTypes;
> +  UniqueTypes.resize(RetainedTypes.size() * 2);
> +  for (auto &RT : RetainedTypes) {
> +    if (!UniqueTypes.insert(RT).second)
> +      continue;
> +    if (auto MD = TypeCache[RT])
> +      DBuilder.retainType(cast<llvm::DIType>(MD));
> +  }
>
>    DBuilder.finalize();
>  }
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=246210&r1=246209&r2=246210&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Aug 27 16:21:19 2015
> @@ -344,6 +344,9 @@ public:
>    /// Emit an Objective-C interface type standalone debug info.
>    llvm::DIType *getOrCreateInterfaceType(QualType Ty, SourceLocation Loc);
>
> +  /// Emit standalone debug info for a type.
> +  llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation
> Loc);
> +
>    void completeType(const EnumDecl *ED);
>    void completeType(const RecordDecl *RD);
>    void completeRequiredType(const RecordDecl *RD);
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150827/a25a8246/attachment.html>


More information about the cfe-commits mailing list