[LLVMdev] RFC: Indexing of structs vs arrays in getelementpointer

Chandler Carruth chandlerc at google.com
Thu May 22 15:51:39 PDT 2014


On Thu, May 22, 2014 at 4:42 PM, Louis Gerbarg <lgg at apple.com> wrote:

> The problem that the above transform is technically illegal because “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).” rule <
> http://llvm.org/docs/LangRef.html#getelementptr-instruction>.
>

Wait, I don't follow. You don't violate this rule. The first index in GEP
is *not* into the structure, it is along the implicit array of objects that
any pointer refers to. Thus the i64 operand to the first GEP selects a
different struct object in an array of them, and the first i64 operand to
the second GEP re-selects the same struct object but then uses an i32 index
into it.

Perhaps you need a better example to show the illegal transform? That would
help me understand the rest of your problem.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140522/fb4d074e/attachment.html>


More information about the llvm-dev mailing list