How to get register name from llvm download instruction

I am trying to get the name of the register in which the load load result is stored from the LoadInst pointer.
For example, if my loadInst pointer points to this command % 0 = load i32 *% i, align 4 , then how can I get% 0 from the instruction?

+4
source share
2 answers

This %0is the name of the command, not the name of the register — there are no registers in the intermediate LLVM view.

In any case, all commands inherit from the class Valuethat defines the method getName()and what you should call. However, keep in mind that usually the command will be unnamed and thus getName()will not return anything useful - names such as %0are assigned only when the module is emitted as text and do not exist before that.

+4
source

CallInst displays a Value so that you can get getName (). However, the value is unnamed (it has a name like% 0), this will not work, since the tt value does not make sense to return. So, if you want to get a name, you must give it a name.

+1
source

All Articles