LLVM - How to get the result variable of an instruction

I start with LLVM and I have a simple problem, but I can not find a solution in the documentation.

I am skipping a function that computes according to instructions, and for this I need all the "data" from the instruction, I mean the operator, all the operands and the result.

My problem is that I cannot get the result variable. For example, for an instruction:

%add1 = add nsw i32 %x, %y

I can have x and y name and variable, I can have opCode, I can have the name add1, but I cannot have the variable add1.

I read all the functions from the Instruction documentation page, and I cannot find anything similar to what I am looking for.

So, what is the correct API that can solve my problem?

+4
source share
1 answer

Instructioninherits from Valueand therefore has a method getName()that solves your problem. But remember that the instruction may be unnamed (for example %0) and getNameprobably will not return anything useful in this case

+4
source

All Articles