[LLVMdev] PointerIntPair causing trouble

Chris Lattner clattner at apple.com
Fri May 1 09:04:49 PDT 2009


On May 1, 2009, at 6:09 AM, Stefanus Du Toit wrote:

> Hi Nicolas,
>
> On 1-May-09, at 6:32 AM, Nicolas Capens wrote:
>> I’ve located a regression that causes my project to crash. It’s in  
>> revision 67979, where PointerIntPair is changed from storing the  
>> integer in the upper bits instead of the lower bits. My project is  
>> an experimental JIT-compiler in Windows.
>
> We're looking into a similar bug right now. We see the problem  
> elsewhere (early on in optimization, during the first instcombine  
> pass) but it sounds like the same issue. We'll let you know when we  
> know more.
>
>> So I was wondering if anyone had any clue why the new  
>> PointerIntPair implementation might fail. It doesn’t seem very safe  
>> to me to store other data into a pointer to begin with, but surely  
>> the lower bits must be a safer location than the upper bits?
>
> Just to be clear, PointerIntPair doesn't (AFAIK) store the integer  
> in the "high bits" of the pointer. It just uses the "higher parts"  
> of the "low available bits" of the pointer. So, if a pointer is  
> always aligned such that it always has 4 bits clear on the low side,  
> and you only need to store one bit, it'll be stored in bit 3  
> (counting from the LSB towards the MSB).

FWIW, the reason it does this is to allow composable pointerintpairs,  
for example, PointerIntPair< PointerIntPair<foo*, 1>, 2> can use the  
low 3 bits as two different bitfields.

-Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090501/3af56906/attachment.html>


More information about the llvm-dev mailing list