[PATCH] D99660: Use DL.getIndexType() in Value::getPointerAlignment()

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 31 08:04:15 PDT 2021


arichardson added a comment.

In D99660#2661453 <https://reviews.llvm.org/D99660#2661453>, @lebedev.ri wrote:

> In D99660#2661435 <https://reviews.llvm.org/D99660#2661435>, @nikic wrote:
>
>> It's not really clear why using the index type for this would be correct. The index type is used for GEP index and casting a pointer to the index type doesn't make a whole lot of sense to me. Do you have any LangRef wording or other usages that would show that this is a sensible thing to do?
>
> +1, i'm not convinced that `index type` is the right fix here.
> I would think that you need to either unbreak the invariant that `decltype(sizeof(ptr))==intptrtype`
> or make that addressspace non-integral, thus preventing int<->ptr casts.

We use something similar to non-integral pointers, but our fork pre-dates that work so we use DL.isFatPointer() instead.
I have been meaning make use of the non-integral pointer work for a long time but it's too strict for our purposes:
For CHERI pointers, inttoptr should be avoided, but ptrtoint is perfectly fine (you just get the address part and not the additional metadata).

My understanding of D42123 <https://reviews.llvm.org/D42123> was that the index width is the number of bits that are affected by pointer arithmetic (i.e. the range of the pointer, 64 bits for our 128-bit capabilities).
If you disagree with that interpretation I guess I can to add another DataLayout field to pointer types that specifies the address range?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99660/new/

https://reviews.llvm.org/D99660



More information about the llvm-commits mailing list