I want to be able to do two things with LLVM (both just before code
1. Insert a MachineBasicBlock just before a MachineBasicBlock.
There is a function called AddPredecessor(). However, the comment says that
it does not update the actual CFG. I want to redirect all CFG edges that are
incoming to this MachineBasicBlock to the new one I create, and add just one
outgoing edge (no branch) to the newly formed MachineBasicBlock to jump to
the original MachineBasicBlock. How can I do this?
2. Insert a bunch of MachineInstructions at arbitrary points inside a
Using the BuildMI function, I can add an arbitrary instruction just before
the position of a MachineBasicBlock::iterator. After the BuildMI function,
is the MachineBasicBlock::iterator still valid? What if I want to insert an
instruction before the newly added instruction? How should I do that?
Some general questions:
Why are there multiple MachineBasicBlocks per BasicBlock? What is the
motivation behind this representation?
Is there any example in the codebase of doing the above?