[LLVMdev] Splitting a MachineBasicBlock in two

Jan Teske jan.teske at gmail.com
Tue Nov 25 03:03:57 PST 2014


Hello,

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!
Jan



More information about the llvm-dev mailing list