[LLVMdev] Inserting MachineBasicBlock(s) before a MachineBasicBlock

madiyaan ahmadsharif at hotmail.com
Tue Sep 30 10:39:56 PDT 2008


I want to be able to do two things with LLVM (both just before code
emission):

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
MachineBasicBlock.
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? 

Thanks,
-- 
View this message in context: http://www.nabble.com/Inserting-MachineBasicBlock%28s%29-before-a-MachineBasicBlock-tp19746986p19746986.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.




More information about the llvm-dev mailing list