<div dir="ltr">Hi<div><br></div><div>I am developing some machine function pass.</div><div><br></div><div>I want to split MachineBasicBlcok when I find some specific machine instruction.</div><div><br></div><div>But I don't insert or delete any machine instruction.</div><div><br></div><div>I just "simply" , "purely" split the MachineBasicBlcok. </div><div><br></div><div>(So, I stole the idea from ARM64BranchRelaxation::splitBlockBeforeInstr.)</div><div><br></div><div>This is my code :</div><div><br></div><div>// I would pass call instruction to this function</div><div><br></div><div>void split_mbb(MachineInstr* mi){<br></div><div>  MachineBasicBlock* mbb=mi->getParent();<br>  MachineFunction* mf=mbb->getParent();<br>  MachineBasicBlock* new_mbb=mf->CreateMachineBasicBlock(mbb->getBasicBlock());<br>       <br>  MachineFunction::iterator mbb_it(mbb);<br>  mf->insert(mbb_it,new_mbb);<br>  new_mbb->splice(new_mbb->end(),mbb,mbb->begin(),mi);<br>}<br></div><div><br></div><div>Originally, mi is in BB. </div><div>(mi would be a call instruction)</div><div>(do not consider mi is a branch instruction) </div><div>BB --> BB1 , BB2  <br></div><div>Then, I split BB, mi is the first instruction of BB2.</div><div>And the instructions before mi are in BB1.</div><div><br></div><div></div><div>But now, I use  my machine function pass to compile some test programs.</div><div><br></div><div>And these test programs can't execute ,  always segment fault.</div><div> </div><div>Is there any problem in my split_mbb ?</div><div><br></div><div>How to "simply" split MachineBasicBlock ?</div><div><br></div><div>Thank you !!</div><div><br></div><div><br></div></div>