[LLVMdev] Getting the target information of a branch instruction

Chris Lattner sabre at nondot.org
Mon Jul 2 14:33:11 PDT 2007


On Mon, 2 Jul 2007 abhi232 at cc.gatech.edu wrote:
> Hello all,
> I am new to the llvm infrastructure so if this question is already
> resolved please redirect me to that link.
>
> I am writing a pass for flow sensitive and context sensitive alias
> analysis.for that i require the previous and next instruction of all the
> instructions.Is there an intrinsic that can help me getting the
> instruction numbers directly because i read at the llvm.org website making
> changes to instruction class may be lead to unstableness..Also if i have a
> branch instruction how do i get he target of the branch instruction.All i
> could find was machine independent target code.

Is this in the code generator, or in the LLVM IR?   I assume that you mean 
the LLVM IR.  Given an unconditional branch, you can use I->getOperand(0) 
to get the destination.  You should check out this document, it describes 
lots of interesting stuff:
http://llvm.org/docs/ProgrammersManual.html

in particular:
http://llvm.org/docs/ProgrammersManual.html#common

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/



More information about the llvm-dev mailing list