<p>Hi Oscar:<br>
In instructions like the one I showed can I expect that Value::use_begin and Value::use_end will return only the getelementptr or there is a chance I will get other users of that constant?<br>
Thanks a lot,<br>
Eduardo </p>
<div class="gmail_quote">On Jan 8, 2013 9:39 PM, "Óscar Fuentes" <<a href="mailto:ofv@wanadoo.es">ofv@wanadoo.es</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Eduardo <<a href="mailto:erocha.ssa@gmail.com">erocha.ssa@gmail.com</a>> writes:<br>
<br>
> How can I get a reference to an instruction if I have a reference to<br>
> an operand? For example, let suppose I have a reference to the<br>
> ConstantExpr "getelementptr inbounds" in the following instruction:<br>
><br>
>   %4 = getelementptr i32* getelementptr inbounds ([8 x i32]*<br>
> @__mem_grid_MOD_nnyp, i32 0, i32 0), i32 %3<br>
><br>
> then, how can I get a reference to the GetElementPtrInst object?<br>
<br>
A given Value instance can be an operand of multiple instructions.<br>
<br>
> The reason I need that is because I want to change every instruction<br>
> that uses certain variables (in the example above the<br>
> __mem_grid_MOD_nnyp variable). The problem is that for the example I<br>
> showed the actual user of the variable is a ConstantExpr object and<br>
> not the GetElementPtrInst object.<br>
<br>
You can traverse the User's of a Value with the iterators returned by<br>
Value::use_begin and Value::use_end methods.<br>
<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>