[LLVMdev] (GEP) Index validity

Matthijs Kooijman matthijs at stdin.nl
Mon Jul 7 03:50:11 PDT 2008


Hi all,

I'm fiddling around a bit with programmatically created GEP instructions,
which is failing when using i64 for any indix, except the first.

The reason behind this, is that StructureType::indexValid only accepts Value*
that are constant ints of width 32. I can't really see why this limitation is
here.

SequentialType solves this slightly differently, it allows for both 32 and 64
bits integers. However, AFAICS, any constant integer should do just fine, so I
would propose to drop the bitwidth check such that any ConstantInt is valid.

This change should also be made to SequentialType, which can be indexed by any
integer type as well.

I've attached a patch, which makes any integer type valid for indexing an
CompositeType. The side effect is now that GEP no longer poses any conditions
on it's indices (since it delegated that to indexValid, which is not the right
place IMHO). I guess those checks need to explicitely added somewhere in
GetElementPtrInst.

Gr.

Matthijs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: indexvalid.diff
Type: text/x-diff
Size: 896 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080707/35e6c5d7/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080707/35e6c5d7/attachment.sig>


More information about the llvm-dev mailing list