[LLVMdev] Splitting a MachineBasicBlock in two
qcolombet at apple.com
Mon Dec 1 11:22:23 PST 2014
I think what you are looking for is: MachineBasicBlock::splice (the version with the range).
Then, indeed, you will have to update the CFG.
IIRC you should find examples on how to do that by looking at the uses of splice.
On Nov 25, 2014, at 3:03 AM, Jan Teske <jan.teske at gmail.com> wrote:
> I am writing a pre-emit pass on the MI-layer in which I would like to
> replace call instructions with a push and a jmp each. Until now, I
> figured that I have to do the following things:
> 1. Split the MachineBasicBlock after the call instruction ==> MBB1, MBB2
> 2. Delete the call instruction
> 3. Push address of MBB2
> 4. Add a jmp to the original call destination at the end of MBB1
> Step 1 troubles me. I have no idea how to perform the split correctly.
> Maybe I could create a new MachineBasicBlock and copy all the
> instructions after the call into it. But then I would also have to
> update the CFG manually, no? Is there a better way to do this? Or can
> someone point me to some documentation/example code?
> Thanks in advance!
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
More information about the llvm-dev