1

The branch instruction contains labels which are the names of the basicblocks that it might jump to. Given that, is there a way to extract a MachineBasicBlock object from a branching instruction? for example:

for(MachineBasicBlock &BB : MF){
    for(MachineInstr &MI : BB){
      if(MI.isConditionalBranch()){
        MachineBasicBlock &InstBB = something(MI.getOperand(0));
      }
    }
  }
CodeHoarder
  • 272
  • 1
  • 11

1 Answers1

1

First you cast MI's operand to BasicBlockSDNode and then use getBasicBlock(). Remember to perform the casting using LLVM cast<>() function.

arrowd
  • 33,231
  • 8
  • 79
  • 110