[LLVMdev] how to get MachineBasicBlock of a BasicBlock

David Meyer pdox at google.com
Fri Oct 15 05:51:58 PDT 2010


Also note: there may be multiple MachineBasicBlock's for a single
BasicBlock.

- David M


On Fri, Oct 15, 2010 at 4:59 AM, Jeff Kunkel <jdkunk3 at gmail.com> wrote:

> 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
> >
> >
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101015/524f13f3/attachment.html>


More information about the llvm-dev mailing list