<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 27, 2015, at 2:25 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Aug 27, 2015 at 2:21 PM, Adrian Prantl via cfe-commits <span dir="ltr" class=""><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-commits@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: adrian<br class="">
Date: Thu Aug 27 16:21:19 2015<br class="">
New Revision: 246210<br class="">
<br class="">
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D246210-26view-3Drev&d=BQMFaQ&c=eEvniauFctOgLOKGJOplqw&r=cTx6f1tAfqPeajYunFWp7_8ot79RnHyNteqzig4fXmA&m=Sj8qkz7sVxvG7N0vgi_JQdPVjDsDVL7hEAG9mK6e4_c&s=aJRwlazZQeqQe80mCWYKzjxquHaBvqmkRAL1J7k0HoE&e=" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=246210&view=rev</a><br class="">
Log:<br class="">
CGDebugInfo: Factor out a getOrCreateStandaloneType() method.<br class="">
<br class="">
Usually debug info is created on the fly while during codegen.<br class="">
With this API it becomes possible to create standalone debug info<br class="">
for types that are not referenced by any code, such as emitting debug info<br class="">
for a clang module or for implementing something like -gfull.<br class="">
Because on-the-fly debug info generation may still insert retained types<br class="">
on top of them, all RetainedTypes are uniqued in CGDebugInfo::finalize().<br class=""></blockquote><div class=""><br class=""></div><div class="">I don't quite understand why the new uniquing code is required - what is it about this new codepath that necessitates that?</div></div></div></div></div></blockquote><div><br class=""></div><div>getOrCreateStandaloneType() invokes getOrCreateType() and adds the DIType to RetainedTypes so it doesn’t get lost. If getOrCreateType() was in fact a cache hit, it is possible that the type was already retained when it was initially created. Thinking of it, it is probably better to make getOrCreateStandalaoneType() replicate getOrCreateType()’s logic and have it only retain the type if it was a cache miss. I’ll fix that.</div><div><br class=""></div><div>-- adrian</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br class="">
Modified:<br class="">
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br class="">
cfe/trunk/lib/CodeGen/CGDebugInfo.h<br class="">
<br class="">
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br class="">
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_CodeGen_CGDebugInfo.cpp-3Frev-3D246210-26r1-3D246209-26r2-3D246210-26view-3Ddiff&d=BQMFaQ&c=eEvniauFctOgLOKGJOplqw&r=cTx6f1tAfqPeajYunFWp7_8ot79RnHyNteqzig4fXmA&m=Sj8qkz7sVxvG7N0vgi_JQdPVjDsDVL7hEAG9mK6e4_c&s=tu3fprD1M6lqLHkpJc-IasxvMhIesAykH_SLNHiYl8g&e=" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=246210&r1=246209&r2=246210&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br class="">
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Aug 27 16:21:19 2015<br class="">
@@ -1398,8 +1398,15 @@ llvm::DIType *CGDebugInfo::getOrCreateRe<br class="">
<br class="">
llvm::DIType *CGDebugInfo::getOrCreateInterfaceType(QualType D,<br class="">
SourceLocation Loc) {<br class="">
+ return getOrCreateStandaloneType(D, Loc);<br class="">
+}<br class="">
+<br class="">
+llvm::DIType *CGDebugInfo::getOrCreateStandaloneType(QualType D,<br class="">
+ SourceLocation Loc) {<br class="">
assert(DebugKind >= CodeGenOptions::LimitedDebugInfo);<br class="">
+ assert(!D.isNull() && "null type");<br class="">
llvm::DIType *T = getOrCreateType(D, getOrCreateFile(Loc));<br class="">
+ assert(T && "could not create debug info for type");<br class="">
RetainedTypes.push_back(D.getAsOpaquePtr());<br class="">
return T;<br class="">
}<br class="">
@@ -3360,9 +3367,14 @@ void CGDebugInfo::finalize() {<br class="">
<br class="">
// We keep our own list of retained types, because we need to look<br class="">
// up the final type in the type cache.<br class="">
- for (std::vector<void *>::const_iterator RI = RetainedTypes.begin(),<br class="">
- RE = RetainedTypes.end(); RI != RE; ++RI)<br class="">
- DBuilder.retainType(cast<llvm::DIType>(TypeCache[*RI]));<br class="">
+ llvm::DenseSet<void *> UniqueTypes;<br class="">
+ UniqueTypes.resize(RetainedTypes.size() * 2);<br class="">
+ for (auto &RT : RetainedTypes) {<br class="">
+ if (!UniqueTypes.insert(RT).second)<br class="">
+ continue;<br class="">
+ if (auto MD = TypeCache[RT])<br class="">
+ DBuilder.retainType(cast<llvm::DIType>(MD));<br class="">
+ }<br class="">
<br class="">
DBuilder.finalize();<br class="">
}<br class="">
<br class="">
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h<br class="">
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_CodeGen_CGDebugInfo.h-3Frev-3D246210-26r1-3D246209-26r2-3D246210-26view-3Ddiff&d=BQMFaQ&c=eEvniauFctOgLOKGJOplqw&r=cTx6f1tAfqPeajYunFWp7_8ot79RnHyNteqzig4fXmA&m=Sj8qkz7sVxvG7N0vgi_JQdPVjDsDVL7hEAG9mK6e4_c&s=wP5t1N1vlukZeQ4hJZIPNg3aK6A2hiDY3de2dsFzjzQ&e=" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=246210&r1=246209&r2=246210&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)<br class="">
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Aug 27 16:21:19 2015<br class="">
@@ -344,6 +344,9 @@ public:<br class="">
/// Emit an Objective-C interface type standalone debug info.<br class="">
llvm::DIType *getOrCreateInterfaceType(QualType Ty, SourceLocation Loc);<br class="">
<br class="">
+ /// Emit standalone debug info for a type.<br class="">
+ llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation Loc);<br class="">
+<br class="">
void completeType(const EnumDecl *ED);<br class="">
void completeType(const RecordDecl *RD);<br class="">
void completeRequiredType(const RecordDecl *RD);<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
cfe-commits mailing list<br class="">
<a href="mailto:cfe-commits@lists.llvm.org" class="">cfe-commits@lists.llvm.org</a><br class="">
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Dcommits&d=BQMFaQ&c=eEvniauFctOgLOKGJOplqw&r=cTx6f1tAfqPeajYunFWp7_8ot79RnHyNteqzig4fXmA&m=Sj8qkz7sVxvG7N0vgi_JQdPVjDsDVL7hEAG9mK6e4_c&s=KP-TI2iE4gchlGzoSv2inSkjBdaf_Vm8z5phvDG_pyk&e=" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br class="">
</blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>