r248826 - CGDebugInfo: Don't reuse a reference into a DenseMap if the DenseMap may
David Blaikie via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 29 16:09:22 PDT 2015
On Tue, Sep 29, 2015 at 4:01 PM, Adrian Prantl <aprantl at apple.com> wrote:
>
> On Sep 29, 2015, at 3:52 PM, David Blaikie <dblaikie at gmail.com> wrote:
>
>
>
> On Tue, Sep 29, 2015 at 1:44 PM, Adrian Prantl via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
>
>> Author: adrian
>> Date: Tue Sep 29 15:44:46 2015
>> New Revision: 248826
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=248826&view=rev
>> Log:
>> CGDebugInfo: Don't reuse a reference into a DenseMap if the DenseMap may
>> be modified in between. (NFC)
>>
>> Modified:
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=248826&r1=248825&r2=248826&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Sep 29 15:44:46 2015
>> @@ -1680,9 +1680,9 @@ CGDebugInfo::getOrCreateModuleRef(Extern
>> // nullptr if the "Module" is a PCH, which is safe because we don't
>> // support chained PCH debug info, so there can only be a single PCH.
>> const Module *M = Mod.getModuleOrNull();
>> - auto &ModRef = ModuleCache[M];
>> - if (ModRef)
>> - return cast<llvm::DIModule>(ModRef);
>> + auto ModRef = ModuleCache.find(M);
>> + if (ModRef != ModuleCache.end())
>> + return cast<llvm::DIModule>(ModRef->second);
>>
>
> Maybe change this to:
>
> if (const auto *Mod = ModuleCache[M])
> return cast<llvm::DIModule>(Mod);
>
> Or similar, to reduce variable scope, since "ModRef" isn't needed/used
> after this block.
>
> 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.
>
>
> 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).
>
Fair enough (:
>
> -- adrian
>
>
>
>>
>> // Macro definitions that were defined with "-D" on the command line.
>> SmallString<128> ConfigMacros;
>> @@ -1724,7 +1724,7 @@ CGDebugInfo::getOrCreateModuleRef(Extern
>> llvm::DIModule *DIMod =
>> DBuilder.createModule(Parent, Mod.getModuleName(), ConfigMacros,
>> Mod.getPath(),
>> CGM.getHeaderSearchOpts().Sysroot);
>> - ModRef.reset(DIMod);
>> + ModuleCache[M].reset(DIMod);
>> return DIMod;
>> }
>>
>>
>>
>> _______________________________________________
>> 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/20150929/4434b032/attachment-0001.html>
More information about the cfe-commits
mailing list