[PATCH] Make StringMap aware of POD types

Chandler Carruth chandlerc at google.com
Mon Mar 17 12:36:18 PDT 2014


On Mon, Mar 17, 2014 at 12:27 PM, Benjamin Kramer <benny.kra at gmail.com>wrote:

> On 17.03.2014, at 20:10, Pete Cooper <peter_cooper at apple.com> wrote:
>
> >
> > On Mar 17, 2014, at 11:57 AM, Benjamin Kramer <benny.kra at gmail.com>
> wrote:
> >
> >>
> >> On 17.03.2014, at 19:47, Pete Cooper <peter_cooper at apple.com> wrote:
> >>
> >>> Hi all
> >>>
> >>> Please review this patch to make StringMap be aware of when it
> contains POD types allocated on a BumpPtrAllocator.  In this case its
> unnecessary to clear the map in its destructor.  This is particularly
> painful on IdentiferTable in clang where we walk an 8192 entry map of
> pointers and uselessly destruct them.
> >>
> >> Ugh. This is really something that the optimizer should do. Have you
> checked
> >> what's preventing LLVM from killing the loop that does nothing?
> > I think it’ll do the right thing in terms of the destructors for each
> element being empty.  The tricky thing is that unless ~StringMap inlines
> clear(), the resetting of all of the elements to the tombstone key will
> also still happen, and on a large map that can be really slow.
>
> In that case, why not just copy the loop into the dtor and remove the
> zeroing there. Thats only a small amount of duplication and should have the
> same effect as your isPODLike contraption.


I strongly prefer this approach to more POD-like hackery here.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140317/e99e2661/attachment.html>


More information about the llvm-commits mailing list