Hi Duncan,
For this example,
getelementptr inbounds [10 x [20 x i32]]* %3, i32 0, i32 %M, i32 %N
I am trying to retrieve %N and instrument the program to see if the value
pointed to by %N exceeds the array bound (10). I assume that
%N will be associated with a load instruction. I have searched through
all the tutorials etc. and still have no clue as to how to do this, that
is,
get the value and then instrument the code.
George
On Mon, Mar 28, 2011 at 4:32 AM, Duncan Sands <baldrick at free.fr> wrote:
> Hi George,
>
> > I am trying to get the first index into this two-dimensional array,
> that is *5.*
>
> not sure what you mean, but if you think of your array as being a 10 x 20
> matrix
> then to get a pointer to element M,N you would do:
> getelementptr inbounds [10 x [20 x i32]]* %3, i32 0, i32 %M, i32 %N
>
> >
> > %4 = getelementptr inbounds [10 x [20 x i32]]* %3, i32 0, i32 *5*
> > *
> > *
> > I can iterate over the GEP and get the types of the operands but not
the
> values.
> >
> > How do I get the value (5)?
>
> getelementptr only does pointer arithmetic, i.e. using it you can get a
> pointer
> to an array element. But to get the element itself you need to use a load
> instruction to load the value pointed to by the pointer.
>
> Ciao, Duncan.
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20110328/98125c13/attachment.html>