[llvm-commits] PATCH: Implement a SmallDenseMap container

Chandler Carruth chandlerc at gmail.com
Sat Jun 16 07:05:42 PDT 2012


And here we are!

Functional highlights:

- Inline buffer will have proper alignment and size constraints, with no
aliasing issues AFAICT.
- Inline buffer re-uses the space typically occupied by the buffer pointer
and buffer size, allowing for example SmallDenseMap<unsigned, unsigned, 2>
to be the same size as DenseMap<unsigned, unsigned>.
- Supports any types DenseMap supports, including those with non-trivial
constructors, destructors, copy constructors, etc.
- Significant attempts to minimize copying, but there is more to do here
(see below).
- Tests are automatically extended to cover the new implementation.

All that said, this patch is still quite rough I'm afraid. There is quite a
bit of duplicated and/or fiddly code that I would like to pull out. It also
needs lots of commenting.

It is surprisingly hard to implement the semantics of a hash-based map with
the small-buffer optimization. This works, but it is far from clean. I hope
it's still acceptable, as I suspect it is worth it in many situations.

I can either try to hack on this patch until it's a bit cleaner and then
submit, or I can submit, and then clean it up incrementally as I go. I only
have a mild preference for the latter approach.

I *think* I have all of the construction / destruction semantics correct,
and I have most of the move semantics correct but not all of them.
Hardening this and adding some tests that exercise at least correct
invocation of constructors and destructors will be important follow-ups to
this.

Anyways, comments welcome!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120616/be1e2a5f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smalldensemap.patch
Type: application/octet-stream
Size: 15784 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120616/be1e2a5f/attachment.obj>


More information about the llvm-commits mailing list