OSDN Git Service

[ptr-traits] Provide a real MCFragment address for the sentinel instead
authorChandler Carruth <chandlerc@gmail.com>
Tue, 29 Dec 2015 09:32:18 +0000 (09:32 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Tue, 29 Dec 2015 09:32:18 +0000 (09:32 +0000)
commita202d8ec2d13b6cf753eae44dbb4cc36542faf30
tree00722236521eb4d0e3a0c8cc40bc1ac5b06c9508
parent5bfe3bbc4729db3672eb33b34ea6770c36c8d372
[ptr-traits] Provide a real MCFragment address for the sentinel instead
of casting the integer '4' to such a pointer. There is no reason to
expect '4' to be a portable or reliable pointer of this form. The only
reason this ever worked is because the PointerIntPair that this actually
gets used with has an artificially *low* presumed alignment that allowed
it to work. When the alignment of PointerIntPair is derived from the
actual type's alignment, the asserts start firing on this pointer. I'm
amazed we never managed to do anything that triggered the alignment
sanitizer with it, as this is just flat out UB.

If folks dislike this approach to providing a sentinel fragment address,
there are a myriad of other alternatives, suggestions welcome. But this
one has the distinct advantage of not requiring the friend dance of
ilist's sentinel (which I'll point out is *also* in play for
MCFragment!) and seems to be using a nicely provided facility in
MCFragment to establish just such dummy nodes.

This is part of a series of patches to allow LLVM to check for complete
pointee types when computing its pointer traits. This is absolutely
necessary to get correct (or reproducible) results for things like how
many low bits are guaranteed to be zero.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256552 91177308-0d34-0410-b5e6-96231b3b80d8
lib/MC/MCSymbol.cpp