[Mlir-commits] [llvm] [mlir] [IR] Require index width to be ule pointer width (PR #70015)
Calvin Beck
llvmlistbot at llvm.org
Mon Jun 29 08:53:39 PDT 2026
Chobbes wrote:
@nikic Oh, I think I see where my confusion is from. I assumed it was the index type of the index in GEP, but...
> The indices are first converted to offsets in the pointer’s index type. If the currently indexed type is a struct type, the struct offset corresponding to the index is sign-extended or truncated to the pointer index type. Otherwise, the index itself is sign-extended or truncated, and then multiplied by the type allocation size (that is, the size rounded up to the ABI alignment) of the currently indexed type.
It's the "pointer index type", which I guess is the raw address bits minus the metadata.
So my concern with stuff like this:
> When indexing into a (optionally packed) structure, only i32 integer constants are allowed (when using a vector of indices they must all be the same i32 integer constant). When indexing into an array, pointer or vector, integers of any width are allowed, and they are not required to be constant. These integers are treated as signed values where relevant.
Was that I could have 64-bit addresses, not necessarily with any metadata like with CHERI. Then my understanding *was* that a structure could never span a 4gb boundary of memory, because then `getelementptr` couldn't index into the later bytes of the structure... But I guess the i32 indices are actually converted to `iPtrIdx` (which isn't real syntax, but a placeholder for `i64` / `i48` / whatever size makes sense for the target architecture?
Thanks! I think that clears things up.
https://github.com/llvm/llvm-project/pull/70015
More information about the Mlir-commits
mailing list