Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the register name from the load instruction in llvm

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

like image 262
ari Avatar asked Jan 04 '14 20:01

ari


1 Answers

That %0 is the instruction's name, not a register name - there are no registers in the LLVM intermediate representation.

In any case, all instructions inherit from the Value class which defines a getName() method, and that's what you should call. However, keep in mind that typically many instruction will be unnamed and thus getName() won't return anything useful - names such as %0 are only assigned when emitting the module as text, and do not exist before that.

like image 148
Oak Avatar answered Oct 06 '22 00:10

Oak