[PATCH] ADT: Remove misaligned pointeres from DenseMapInfo

Chandler Carruth chandlerc at google.com
Thu Jan 8 16:38:51 PST 2015


On Thu, Jan 8, 2015 at 3:59 PM, Duncan P. N. Exon Smith <
dexonsmith at apple.com> wrote:

> > On 2015-Jan-08, at 15:56, Chandler Carruth <chandlerc at google.com> wrote:
> >
> > After arguing about this for like an hour with Richard, David, and
> Alexey, I think we have a better path forward...
> >
> > Much as you suggest, the key is nuking the upcast in the asserts build.
> But we can fix a number of other things in the process. For example, it is
> really annoying that we construct ValueHandle objects for the empty and
> tombstone keys. Instead, it would be better if we could not construct an
> object at all, and it turns out there is a nice way to do this.
>
> Colour me interested...
>
> > Unfortunately, it requires some refactoring to DenseMap and DenseMapInfo
> to expose this freedom. I'm going to do that refactoring (which seems like
> generally good cleanup), and then we can look at a more direct way of
> fixing the bug here.
>
> SGTM!


Bleh. Never mind. Doesn't work. Removing the PointerIntPair still helps,
and I'll submit the obvious patch to do that shortly.

We add a private constructor to AssertingVH that accepts a raw Value* (and
in NDEBUG, store a raw Value*), sinking all the casting into methods. We
ensure the ValueHandleBase can also be constructed for a raw Value* with no
casting. Then we hand in DenseMapInfo<Value *>::getEmptyKey() and
DenseMapInfo<Value *>::getTombstoneKey(). No need to do any other funny
business I think.

At some point, I would really like to also get rid of the shifts in
DenseMapInfo<T*>, but I don't think we need to solve that problem today.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150108/0559a4aa/attachment.html>


More information about the llvm-commits mailing list