Function* func = ...; // Obtain a pointer to a function BasicBlock* block = ...; // Obtain a pointer to a basic block in the function MachineBasicBlock* mbBlock = ...; // Obtain the MachineBasicBlock corresponding to the basic block // Construct a MachineOperand with the block address of the basic block MachineOperand op = MachineOperand::CreateBA(mbBlock->getBlockAddress()); // Use the MachineOperand in a jump instruction MachineInstrBuilder MIBuilder = BuildMI(*mbBlock, /*InsertPoint=*/{}, getJmpOp()) .add(op);
MachineOperand op = ...; // Obtain a MachineOperand with a block address assert(op.isGlobal()); // Make sure that the MachineOperand represents a global value const GlobalValue* val = op.getGlobal(); if (isaThe MachineOperand getBlockAddress function is available in the LLVM core library.(val)) { const BlockAddress* ba = cast (val); uint64_t baValue = ba->getOffset(); // Obtain the offset value of the block address // use baValue as needed }