[llvm] r256620 - [ptr-traits] Implement the base pointer traits using the actual

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 30 06:45:16 PST 2015


On 12/30/2015 05:00 AM, Chandler Carruth via llvm-commits wrote:
> Author: chandlerc
> Date: Tue Dec 29 22:00:24 2015
> New Revision: 256620
>
> URL: http://llvm.org/viewvc/llvm-project?rev=256620&view=rev
> Log:
> [ptr-traits] Implement the base pointer traits using the actual
> alignment of the pointee type!
>
> This is the culmination of the ptr-traits work. Now the compiler will
> catch me if I try to use a pointer to an empty struct as a key in
> a dense map or inside a PointerIntPair or PointerUnion! This is much,
> much better than sometimes corrupting data (and other times working
> fine) due to insufficient alignment.
>
> It also means that we will be much more diligent about rejecting other
> uses of these constructs that aren't safe.
>
> It also means that we can now be more aggressive with the constructs
> when we actually have guaranteed higher alignment without specializing
> stuff. I'll be going through and cleaning up all the current overrides
> of these traits which are no longer necessary.
>
> Many thanks to Richard, David, and others who helped me get all of this
> together.

This broke the use of incomplete types (and as a result Polly). I 
temporarily reverted this commit in 256642.

I spent some more time to look into what the right solution for 
incomplete pointer types might be and came up with three possible solutions:

1) Generally avoid incomplete pointer types

2) Add PointerLikeTypeTraits for any incomplete type used

3) Teach PointerLikeTypeTraits to be conservative in case of incomplete
    types.


1) does not seem to be a solution as in incomplete pointer types are in 
our case used to hide implementation details. I do not think exposing 
the actual type is the right approach.

Solution 2) can be easily implemented (I realized this after reverting). 
I attached a patch that adds two PointerLikeTypeTraits with
"enum { NumLowBitsAvailable = 0 };" for the two incomplete types in
Polly. This is sufficient to pass 'make check'. There are likely more 
bits available, but at least the isl interface does not give any 
guarantees. I assume these patches would be sufficient to get Chandlers 
change while ensuring that Polly still builds. If you think this is 
indeed the right approach, I would be happy to add this to Polly and go
on with life.

Regarding 3), I wonder if we could make the behavior of 2) the default 
for all incomplete types. Maybe there is some C++-magic available that 
would allow us to do this easily?

Best,
Tobias

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-specialized-pointer-type-traits-to-Polly.patch
Type: text/x-patch
Size: 1763 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151230/515b0b96/attachment.bin>


More information about the llvm-commits mailing list