[llvm-dev] How to simply split MachineBasicBlock ?

PenYiWang via llvm-dev llvm-dev at lists.llvm.org
Thu Mar 12 22:19:42 PDT 2020


I am developing some machine function pass.

I want to split MachineBasicBlcok when I find some specific machine

But I don't insert or delete any machine instruction.

I just "simply" , "purely" split the MachineBasicBlcok.

(So, I stole the idea from ARM64BranchRelaxation::splitBlockBeforeInstr.)

This is my code :

// I would pass call instruction to this function

void split_mbb(MachineInstr* mi){
  MachineBasicBlock* mbb=mi->getParent();
  MachineFunction* mf=mbb->getParent();

  MachineFunction::iterator mbb_it(mbb);

Originally, mi is in BB.
(mi would be a call instruction)
(do not consider mi is a branch instruction)
BB --> BB1 , BB2
Then, I split BB, mi is the first instruction of BB2.
And the instructions before mi are in BB1.

But now, I use  my machine function pass to compile some test programs.

And these test programs can't execute ,  always segment fault.

Is there any problem in my split_mbb ?

How to "simply" split MachineBasicBlock ?

Thank you !!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200313/846b7b0e/attachment-0001.html>

More information about the llvm-dev mailing list