[LLVMdev] Def_Use chain

John Criswell criswell at illinois.edu
Mon Jul 25 07:33:40 PDT 2011


On 7/24/11 10:28 AM, neda 8664 wrote:
>
> Hi All
>
>
> I extract Def_Use chain by following code:
>
>
>
> for (Value::use_iterator i = F->use_begin(), e = F->use_end(); i != e; 
> ++i)
>
> if (Instruction *Inst = dyn_cast<Instruction>(*i)) {
>
> errs() << "F is used in instruction:\n";
>
> errs() << *Inst << "\n";
>
> }
>
>
> Now, I want to distinguish the register name or memory variable that 
> lead to this data dependency.
>

Can you clarify what you mean?  Are you talking about LLVM virtual 
registers or physical registers assigned during code generation?

If you're talking about the former, then recall that LLVM IR is in SSA 
form, and each virtual register is equivalent to the instruction that 
defines it.  In other words, a virtual register and the instruction that 
generates its value are one and the same.

So, if you want to know the name of the virtual register for Inst in the 
code above, just call Inst->getName().  The name of the instruction is 
the name of the virtual register it defines.

-- John T.

>
> Thanks
>
>
>
> _______________________________________________
> 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/20110725/3a8b1b68/attachment.html>


More information about the llvm-dev mailing list