Hi
I am developing some machine function pass.
I want to split MachineBasicBlcok when I find some specific machine instruction.
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();
MachineBasicBlock* new_mbb=mf->CreateMachineBasicBlock(mbb->getBasicBlock());
MachineFunction::iterator mbb_it(mbb);
mf->insert(mbb_it,new_mbb);
new_mbb->splice(new_mbb->end(),mbb,mbb->begin(),mi);
}
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 !!