[LLVMdev] Inserting MachineBasicBlock(s) before a MachineBasicBlock

Dale Johannesen dalej at apple.com
Tue Sep 30 10:48:43 PDT 2008


The BranchFolding code does CFG manipulation along the lines you want,  
although not exactly.
You can probably rephrase what you want to do so that SplitMBBAt works.

On Sep 30, 2008, at 10:39 AMPDT, madiyaan wrote:
> 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.
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list