<p>There is also the Instruction Namer pass that gives all anon registers names.</p>
<div class="gmail_quote">On Jul 5, 2012 10:35 PM, "Igor Merkulow" <<a href="mailto:igor.merkulow@gmail.com">igor.merkulow@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>Hi John,</div><div><br></div><div>%4 is not returned, because it's a temp register value and not a named variable. </div><div>But you can implement something like the code below to get this value.</div><div>(Not the most elegant, but more or less working solution).</div>

<div><br></div><div>static std::string getName(Instruction* i)</div><div>{</div><div>            if(i->getOpcode() == Instruction::Store)</div><div>            {</div><div>                return getName((dyn_cast<StoreInst>(&*i))->getPointerOperand());</div>

<div>            }</div><div>            else if(i->getOpcode() == Instruction::Ret)</div><div>            {</div><div>                return "Return";</div><div>            }</div><div><br></div><div><div>            std::string name;</div>

<div>            raw_string_ostream s(name);</div></div><div><br></div><div>            s << *i; // string representation of an instruction</div><div><br></div><div>            size_t var_start = name.find('%'); // var starts with a %</div>

<div>            size_t var_end = name.find(" ", var_start+1); // till space</div><div>            size_t var_comma = name.find(",", var_start+1); // or comma</div><div><br></div><div>            return var_comma<var_end?</div>

<div>                        name.substr(var_start,var_comma-var_start) :</div><div>                        name.substr(var_start, var_end-var_start);</div><div>}</div><div><br></div><div>Have fun</div><div>Igor</div><br>

<div class="gmail_quote">On Thu, Jul 5, 2012 at 11:15 PM, John Backes <span dir="ltr"><<a href="mailto:back0145@umn.edu" target="_blank">back0145@umn.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hello,<br>
<br>
I'm new to llvm development and I have a question which I think should<br>
be straight forward, but I am having trouble figuring it out.  I want to<br>
be able to access the return variable name for an instruction.  For some<br>
instructions I can get this value through the "getName" method.  For<br>
example, with the instruction:<br>
<br>
 > %arg11 = bitcast i32* %arg1 to i8*, !dbg !42, !id !43<br>
<br>
calling the "getName" method returns:<br>
<br>
 > arg11<br>
<br>
However, for the instruction:<br>
<br>
 > %4 = load i32* %arg1, align 4, !dbg !57, !id !59<br>
<br>
the "getName" method returns the empty string.  How would I find the<br>
value "4" for this load instruction?  Thanks in advance.<br>
<br>
- John<br>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">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>
<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>
<br></blockquote></div>