<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 29, 2015 at 4:01 PM, Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><div><div class="h5"><blockquote type="cite"><div>On Sep 29, 2015, at 3:52 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:</div><br><div><br><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">On Tue, Sep 29, 2015 at 1:44 PM, Adrian Prantl via cfe-commits<span> </span><span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span><span> </span>wrote:<br><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>Date: Tue Sep 29 15:44:46 2015<br>New Revision: 248826<br><br>URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project?rev=248826&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=248826&view=rev</a><br>Log:<br>CGDebugInfo: Don't reuse a reference into a DenseMap if the DenseMap may<br>be modified in between. (NFC)<br><br>Modified:<br>   <span> </span>cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br><br>Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=248826&r1=248825&r2=248826&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=248826&r1=248825&r2=248826&view=diff</a><br>==============================================================================<br>--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br>+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Sep 29 15:44:46 2015<br>@@ -1680,9 +1680,9 @@ CGDebugInfo::getOrCreateModuleRef(Extern<br>   // nullptr if the "Module" is a PCH, which is safe because we don't<br>   // support chained PCH debug info, so there can only be a single PCH.<br>   const Module *M = Mod.getModuleOrNull();<br>-  auto &ModRef = ModuleCache[M];<br>-  if (ModRef)<br>-    return cast<llvm::DIModule>(ModRef);<br>+  auto ModRef = ModuleCache.find(M);<br>+  if (ModRef != ModuleCache.end())<br>+    return cast<llvm::DIModule>(ModRef->second);<br></blockquote><div><br></div><div>Maybe change this to:<br><br>if (const auto *Mod = ModuleCache[M])<br>  return cast<llvm::DIModule>(Mod);<br><br>Or similar, to reduce variable scope, since "ModRef" isn't needed/used after this block.<br><br>It does cause the entry to be created earlier, but that shouldn't make a difference in any real sense - but I could see a preference either way, if you prefer it the way it is, that'd be cool too.</div></div></div></blockquote><div><br></div></div></div>I thought about both variants, but then decided for myself that I disliked default-creating the entry just a tiny bit more. (In this particular case it is really cheap of course).</div></div></blockquote><div><br></div><div>Fair enough (:</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span class="HOEnZb"><font color="#888888"><div><br></div></font></span><div><span class="HOEnZb"><font color="#888888">-- adrian</font></span><span class=""><br><blockquote type="cite"><div><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div> </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>   // Macro definitions that were defined with "-D" on the command line.<br>   SmallString<128> ConfigMacros;<br>@@ -1724,7 +1724,7 @@ CGDebugInfo::getOrCreateModuleRef(Extern<br>   llvm::DIModule *DIMod =<br>       DBuilder.createModule(Parent, Mod.getModuleName(), ConfigMacros,<br>                             Mod.getPath(), CGM.getHeaderSearchOpts().Sysroot);<br>-  ModRef.reset(DIMod);<br>+  ModuleCache[M].reset(DIMod);<br>   return DIMod;<br> }<br><br><br><br>_______________________________________________<br>cfe-commits mailing list<br><a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a></blockquote></div></div></blockquote></span></div><br></div></blockquote></div><br></div></div>