This is an archive of the discontinued LLVM Phabricator instance.

Fix -fsanitize=alignment reports on DenseMap empty/tombstone keys.
AbandonedPublic

Authored by samsonov on Dec 22 2014, 7:53 PM.

Details

Reviewers
chandlerc
rsmith
Summary

Use large alignment when calculating empty/tombstone keys
for T*. We can't use alignof(T), as T may be forward-declared at
this point, and PointerLikeTypeTraits<T*>::NumLowBitsAvailable may
be too small.

Diff Detail

Event Timeline

samsonov updated this revision to Diff 17583.Dec 22 2014, 7:53 PM
samsonov retitled this revision from to Fix -fsanitize=alignment reports on DenseMap empty/tombstone keys..
samsonov updated this object.
samsonov edited the test plan for this revision. (Show Details)
samsonov added reviewers: chandlerc, rsmith.
samsonov added a subscriber: Unknown Object (MLST).
chandlerc edited edge metadata.Dec 22 2014, 8:13 PM

I'm curious why we need to support forward declared types. It seems really
brittle. Have you looked into this much? If not, I can.

I had a similar patch here: http://reviews.llvm.org/D5428

I went with a different approach to handle global objects which were massively over-aligned (unlikely, but possible).

include/llvm/ADT/DenseMapInfo.h
38–47

Would using std::max make this more readable?

I'm curious why we need to support forward declared types. It seems really
brittle. Have you looked into this much? If not, I can.

If your class has a member llvm::DenseMap<llvm::AllocaInst *, Foo>, it's a common practice to forward-declare llvm::AllocaInst.

I had a similar patch here: http://reviews.llvm.org/D5428

I went with a different approach to handle global objects which were massively over-aligned (unlikely, but possible).

Right, your patch looks slightly better. I'd be happy to see either of these commited :)

include/llvm/ADT/DenseMapInfo.h
38–47

This header is included by almost every LLVM source. I didn't want to #include <algorithm> here.

samsonov abandoned this revision.Jan 9 2015, 12:43 PM