Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LLVM - How to get the result variable of an instruction

I'm a beginner with LLVM, and I have a simple problem, but I can't find the solution in the documentation.

I'm doing a function pass that computes on instructions, and for this I need all 'data' from the instruction, I mean the operator, all operands, and the result.

My problem is, I can't get the result variable. For example, for the instruction:

%add1 = add nsw i32 %x, %y

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

I read all functions from the Instruction page of the documentation, and I can't find anything who looks like what I'm looking for.

So what is the proper API that can solve my problem?

like image 364
Phantom Avatar asked Apr 16 '15 20:04

Phantom


1 Answers

Instruction inherits from Value and thus has method getName() which solves your problem. But remember that instruction can be unnamed (such as %0) and getName probably won't return anything useful in that case

like image 175
evagl Avatar answered Oct 13 '22 23:10

evagl