[LLVMdev] How can I get the destination operand of an instruction?

Cheng Liu st.liucheng at gmail.com
Thu May 10 00:06:36 PDT 2012


I read previous link according to your suggestion, and find that the 
pointers of basicblock, instruction, operand can display strings like 
'0x908784' using errs()<<*ptr
Theses strings are unique representation for different instruction 
instances, basic blocks and variables. Thus they can help me to build 
data flow graph in operand level.

Thank you very much.

On 5/9/2012 11:14 AM, =?utf-8?Q?=C3=93scar_Fuentes?= wrote:
> Launcher<st.liucheng at gmail.com>  writes:
>
>> I am able to access the source operands of an instruction using either
>> getOperand() or op_iterator, However, I can't find any method available for
>> destination operand. Someone suggests that instruction itself can represent
>> the destination operand.
>> http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-January/037518.html
> That's correct: the llvm::Instruction itself represents the result of
> the operation. Note that class llvm::Instruction derives from
> llvm::Value through llvm::User.
>
>> The getOperand() returns an unsigned value like 0x9063498,
> Uh? User::getOperand returns a Value*.
>
>> while I can't
>> find any instruction's method that returns unsigned value. I have tried
>> getValue(),
> You mean Value::getValueID, don't you?
>
>> but it actually returns the opcode of the instruction instead of
>> a unique value of of an instruction instance.
>>
>> Anyone gives any suggestions about this?
> Read again the message you linked at the beginning.


-- 
Cheng Liu
PhD Candidate
Department of Electrical and Electronic Engineering
The University of Hong Kong




More information about the llvm-dev mailing list