[LLVMdev] CFG modifcations and code gen

Chris Lattner clattner at apple.com
Tue Oct 14 17:37:58 PDT 2008


On Oct 14, 2008, at 4:19 PM, Villmow, Micah wrote:

> After a bunch more investigate, I’ve seem to have figured out what  
> is going on here. The MachineFunction holds a vector of  
> MachineBasicBlocks and it is this vector that is traversed by the  
> MachineFunction iterator when printing out instructions. The problem  
> is occurring when a modification to the CFG moves around so that the  
> ordering of them is different. Even if the pred/succ blocks are  
> modified, their position in the MBBNumbering vector does not change.  
> This causes the CFG graph and the MachineFunction vector to become  
> out of sync causing all sorts of issues with code generation. (i.e.  
> having my return block being generated in the middle of a loop).
>
> I figured that sorting the vector based on the block id’s would fix  
> this issue, but the constructor required to sort correctly is marked  
> as private.
>
> So, my basic need is this. How do I re-order the MachineBasicBlocks  
> vector based on their Block ID numbers via the current API(2.3)?

The branch folding pass moves around blocks, please take a look at its  
implementation to see how it works,

-Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20081014/efc14b82/attachment.html>


More information about the llvm-dev mailing list