<meta charset="utf-8"><div>Hi Duncan,</div><div> For this example, </div>  getelementptr inbounds [10 x [20 x i32]]* %3, i32 0, i32 %M, i32 %N<div>I am trying to retrieve %N and instrument the program to see if the value </div>
<div>pointed to by  %N exceeds the array bound (10). I assume that </div><div>%N will be associated with a load instruction. I have searched through </div><div>all the tutorials etc. and still have no clue as to how to do this, that is, </div>
<div>get the value and then instrument the code. </div><div><br></div><div>George </div><div><br></div><div><div class="gmail_quote">On Mon, Mar 28, 2011 at 4:32 AM, Duncan Sands <span dir="ltr"><<a href="mailto:baldrick@free.fr">baldrick@free.fr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi George,<br>
<br>
>    I am trying to get the first index into this two-dimensional array, that is *5.*<br>
<br>
not sure what you mean, but if you think of your array as being a 10 x 20 matrix<br>
then to get a pointer to element M,N you would do:<br>
   getelementptr inbounds [10 x [20 x i32]]* %3, i32 0, i32 %M, i32 %N<br>
<div class="im"><br>
><br>
> %4 = getelementptr inbounds [10 x [20 x i32]]* %3, i32 0, i32 *5*<br>
> *<br>
> *<br>
> I can iterate over the GEP and get the types of the operands but not the values.<br>
><br>
> How do I get the value (5)?<br>
<br>
</div>getelementptr only does pointer arithmetic, i.e. using it you can get a pointer<br>
to an array element.  But to get the element itself you need to use a load<br>
instruction to load the value pointed to by the pointer.<br>
<br>
Ciao, Duncan.<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</blockquote></div><br></div>