[LLVMdev] how to get MachineBasicBlock of a BasicBlock

Jeff Kunkel jdkunk3 at gmail.com
Fri Oct 15 04:59:53 PDT 2010


I don't think you can.

The BasicBlock is a member of MachineBasicBlock. It is not inherited,
so it cannot be cast. The number of the MachineBasicBlock is not the
same as any BasicBlock values. So
MachineFunction::getMachineBasicBlock( BasicBlock::{get the number} )
cannot work. I do not see much in the basic block which can identify
it.

So you can search for it.

typedef struct findBlock {
  BasicBlock * block;
  findBlock( BasicBlock * block ) : block(block) {}
  bool operator( MachineBasicBlock * mbb ) { return
mbb->getBasicBlock() == block; }
} findBlock;
MachineBasicBlock = *std::find( machineFunction.begin(), machineFunction.end(),
  findBlock( basicBlock ) );

-Thanks
-Jeff Kunkel

2010/10/15 徐敏 <xm1988 at mail.ustc.edu.cn>:
> Hello, we can get BasicBlock from MachineBasicBlock through MachineBasicBlock::getBasicBlock() function, but how can I get MachineBasicBlock of a BasicBlock?
> Thank you!
>
>
>
>
> _______________________________________________
> 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