[LLVMdev] (GEP) Index validity

Matthijs Kooijman matthijs at stdin.nl
Wed Jul 16 00:58:07 PDT 2008


> I understand what you're trying to do.
Ok :-)

> Why do you want this?  What  value does it add?  Do you need a struct with
> more than 2^32 fields?
It's not really needed, but I think it would be more correct. I did run into
an issue: I was working on argpromotion (see PR2498), which stores lists of
indices. These used to be stored as Value*, but I ran into type problems. For
example, when there is a load gep {...} %X, i32 0 in the entry block, and a
load gep {...} %X, i64 0 somewhere else, the argument will not be promoted
because the second load is supposedly not safe (different indices).

I fixed this by replacing the Value* lists with unsigned lists, thus dropping
type information (which wasn't really useful anyway). However, when
regenerating new GEPs from thos lists, I must choose a type again. To make
sure things fit I always used i64, which broke since only i32 was supported.
That's where I started fixing things.

However, as pointed out by evan, i64 is not valid for indexing a struct (per
langref). This means that I should really be emitting GEPs that use an i64 as
the first index (since that indexes a pointer) and i32's for all the next
indices (which index struct elements). This will make things work within the
constraints of GEP again and need any other changes to IndexValid (though I
still think that the checks for the operand types of GEP are in the wrong
place, but it's not really a problem now).

So, problem solved I guess :-) Thanks for the pointers and patience!

Gr.

Matthijs
-------------- 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/20080716/78e6f7d9/attachment.sig>


More information about the llvm-dev mailing list