[LLVMdev] (GEP) Index validity

Evan Cheng evan.cheng at apple.com
Fri Jul 11 10:56:16 PDT 2008


On Jul 10, 2008, at 12:26 PM, Matthijs Kooijman wrote:

> Hi Evan,
>
>
>> I don't think this is right. According to llvm documentation:
>>
>> The index types specified for the 'getelementptr' instruction  
>> depend on the
>> pointer type that is being indexed into. Pointer and array types  
>> can use a
>> 32-bit or 64-bit integer type but the value will always be sign  
>> extended to
>> 64-bits. Structure and packed structure types require i32 constants.
> That's correct. I'm not saying to allow other integer types for GEP
> instructions. The first two methods below are methods in StructType  
> and
> SequentialType. Regardless of any limitations posed by a GEP  
> instruction, I
> argue that "i8 2" is a perfectly valid index for a struct. The fact  
> that it is
> not valid for a GEP instruction, should be checked somewhere else  
> (GEPInst
> constructor or GEPInst::getIndexedValue probably).

That's what the documentation is saying though. Struct and packed  
structure types require i32 constants. Perhaps I am misunderstanding  
something?

Evan

>
>
> The last method in the patch is directly related to GEP indices, so  
> asserting
> only the constness might not be enough, though it would not hurt to  
> make this
> assert slightly more general (ie, don't check the bitwidth as well).
>
> Gr.
>
> Matthijs
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list