yaxunl marked an inline comment as done.
yaxunl added a comment.

In https://reviews.llvm.org/D23361#512729, @Anastasia wrote:

> I think Clang is supposed to generate the IR specific to the target 
> architecture. It seems strange to ignore the pointer size. I am not sure if 
> it might lead to some issues for the backends.


This change only affects AMDGCN target which has different pointer size for 
different address spaces. There is no change for other targets.

For AMDGCN target, since there can be only one definition for size_t type, it 
has to be 64 bit to accommodate all pointers.

For operations not involving pointers, this is fine since it does not matter 
whether size_t is i32 or i64.

For operations involving pointers, it only affects ptrtoint instruction, which 
allows a pointer to be casted to any integer. If the integer size is larger 
than the pointer size, it is zero extended. If the integer is smaller than the 
pointer size, it is truncated.

When clang casts a pointer to size_t, there are two cases:

1. non-private pointers: before this change, it was casted to i32, which is 
wrong. now it is casted to i64 correctly.

2. private pointer: before this change, it was casted to i32, now it is casted 
to i64. It is still correct. Backend should be able to optimize these 
instructions.


https://reviews.llvm.org/D23361



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to