[LLVMdev] Getting the target information of a branch instruction

Tanya M. Lattner tonic at nondot.org
Mon Jul 2 15:16:12 PDT 2007


> Thanks a lot for the information.Actually i am looking for the target of
> conditional branch operation something like

The Programmers Manual that Chris suggested has this kind of information.
http://llvm.org/docs/ProgrammersManual.html#BasicBlock

If this is LLVM IR, get the Terminator instruction from the basic block.

Read up on TerminatorInst:
http://llvm.org/doxygen/classllvm_1_1TerminatorInst.html

For a conditional branch, you will get a BranchInst, check if its 
conditional, and then you can get the successor blocks.

Does this answer your question?

-Tanya

>
> some instruction INST...
> if(condition)
> {
> }
> else
> {
> }..
>
> In this case the next set for the instruction INST will consist of the
> code in the true condition as well as the falses condition....
> for that i am checking if the opcode is terminator and after that i am
> getting the opcode name and if it is a branch instruction then i should
> get the statement number of the branch...i am using a map to associate an
> instruction with number...i had a look at the IR and it has inserted
> cond_true,cond_false and cond_next labels in the IR of the bytecode...
>
> How do i go further with these values in hand?
> please guide on this topic.
> Thanks a lot.
> abhinav.
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>



More information about the llvm-dev mailing list