Def_Use chain

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(*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.

Thanks

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(*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.