<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 3:06 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class="Apple-interchange-newline"><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Thu, Aug 27, 2015 at 2:35 PM, Adrian Prantl<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:aprantl@apple.com" target="_blank" class="">aprantl@apple.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Aug 27, 2015, at 2:25 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank" class="">dblaikie@gmail.com</a>> wrote:</div><br class=""><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 class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-commits@lists.llvm.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: 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:<span class="Apple-converted-space"> </span><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 class=""><br class=""></div></span><div class="">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></div></blockquote><div class=""><br class=""></div><div class="">Why are both functions checking the cache, though? (or does getOrCreateType only retain types that use DIRefs? & then you need to retain the other ones too?)</div></div></div></blockquote><div><br class=""></div><div>In r246231, I fixed it by only retaining types that do not have a UID field (which are the only ones that get retained by DIBuilder.</div><div><br class=""></div><div>-- adrian</div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><div class=""><span class="HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">-- adrian</div></font></span><div class=""><div class="h5"><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: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><br class="">Modified:<br class=""> <span class="Apple-converted-space"> </span>cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br class=""> <span class="Apple-converted-space"> </span>cfe/trunk/lib/CodeGen/CGDebugInfo.h<br class=""><br class="">Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br class="">URL:<span class="Apple-converted-space"> </span><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:<span class="Apple-converted-space"> </span><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" target="_blank" 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></blockquote></div></div></div></div></blockquote></div></div></div></div></blockquote></div></div></blockquote></div><br class=""></body></html>