[llvm-dev] How to simply split MachineBasicBlock ?
PenYiWang via llvm-dev
llvm-dev at lists.llvm.org
Fri Mar 13 04:16:31 PDT 2020
Thank You !!
Help me a lot !!
Craig Topper <craig.topper at gmail.com> 於 2020年3月13日 週五 下午2:36寫道:
> Did you transfer the successors of BB1 to BB2 and add BB2 as a successor
> of BB1? This note in code you referenced refers to that "NOTE: Successor
> list of the original BB is out of date after this function, and must be
> updated by the caller!"
>
> See this code in ARMConstantIslands::splitBlockBeforeInstr
>
> // Update the CFG. All succs of OrigBB are now succs of NewBB.
> NewBB->transferSuccessors(OrigBB);
>
> // OrigBB branches to NewBB.
> OrigBB->addSuccessor(NewBB);
>
>
>
> ~Craig
>
>
> On Thu, Mar 12, 2020 at 10:20 PM PenYiWang via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>
>> 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 !!
>>
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200313/44f583f8/attachment.html>
More information about the llvm-dev
mailing list