MachineBasicBlock *entry = &MF.front(); for (MachineBasicBlock &MBB : MF) { for (MachineInstr &MI : MBB) { if (MI.isCall()) { MachineBasicBlock *target = /* ... */; entry->addSuccessor(target); } } }
MachineBasicBlock *MBB = /* ... */; unsigned Reg = /* ... */; for (MachineInstr &MI : *MBB) { if (MI.isRegTiedToUseOperand(Reg)) { // Do something... } }This example shows how to iterate over the instructions in a single basic block (MBB) and check if a particular register (Reg) is tied to a use operand in any of the instructions. If a tied use operand is found, some operation is performed. Package library: LLVM Core.