Thank you Stephan,<br><br>I solved it already. I copy paste it wrongly. The problem was with an array not well filled.<br><br>Thank you !<br><br><div class="gmail_quote">On Mon, Jan 28, 2013 at 11:53 AM, Stephan Falke <span dir="ltr"><<a href="mailto:falke@iti.uka.de" target="_blank">falke@iti.uka.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Alexandru,<br>
<div class="im"><br>
> The compilation error is : `error: ‘LD100’ was not declared in this scope.`<br>
><br>
> On Mon, Jan 28, 2013 at 11:31 AM, Alexandru Ionut Diaconescu <<br>
> <a href="mailto:alexandruionutdiaconescu@gmail.com">alexandruionutdiaconescu@gmail.com</a>> wrote:<br>
><br>
>> Hello everyone,<br>
>><br>
>> Can you please tell me if it is possible in LLVM to cast a `Value*` to an<br>
>> `Instruction*/LoadInst*` if for example `isa<LoadInst>(MyValue)` is true?<br>
>> In my particular piece of code:<br>
>><br>
>> Value* V1 = icmpInstrArray[i]->getOperand(0);<br>
>> Value* V2 = icmpInstrArray[i]->getOperand(1);<br>
>> if (isa<LoadInst>(V1) || isa<LoadInst>(V2)){<br>
>> ...<br>
>> if(isa<LoadInst>(icmpInstrArray[i]->getOperand(0)))<br>
>> LoadInst *LD100 = cast<LoadInst>(icmpInstrArray[i]->getOperand(0));<br>
>> Value *C100 = LD100->getPointerOperand(); //HERE COMPILATION<br>
>> ERROR<br>
>> Further, I just need to make `C100->getName()` and I will get the loaded<br>
>> variable.<br>
<br>
</div>Looks like you meant to write<br>
<br>
if (isa<LoadInst>(icmpInstrArray[i]->getOperand(0))) {<br>
<div class="im"> LoadInst *LD100 = cast<LoadInst>(icmpInstrArray[i]->getOperand(0));<br>
Value *C100 = LD100->getPointerOperand(); //HERE COMPILATION ERROR<br>
</div> ...<br>
}<br>
<br>
(i.e., you were missing "{...}" after the "if").<br>
<div class="im"><br>
>> I don't think that I can use cast like that. Can you tell me a method to<br>
>> obtain the loaded variable from a Load instruction correspondent to my ICMP<br>
>> instructions? Or better how I can extract the Load instruction from<br>
>> `icmpInstrArray[i]->getOperand(0)`?<br>
>><br>
>> Thank you a lot !<br>
<br>
</div>Hope this helps,<br>
Stephan<br>
<div class="HOEnZb"><div class="h5"><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>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><font style="background-color:rgb(255,255,255);color:rgb(153,153,153)">Best regards,</font><br style="background-color:rgb(255,255,255);color:rgb(153,153,153)">
<font style="background-color:rgb(255,255,255);color:rgb(153,153,153)">Alexandru Ionut Diaconescu</font><br>