Hi, Is it possible to get the list of BasicBlocks building the condition of a loop and the list of BasicBlocks that form the body? My first approach was to iterate over the list of all Basicblocks of a loop and separate the header as the condition and the remaining as the body of the loop. However, this is not correct for instance in the case of a while loop in the form: while( A & B) do { body } My aim is to manipulate for loops, while and do-while loops unitary, but I did not find an easy way to do this. I tried also to apply passes like "Canonicalize natural loops", "Canonicalize Induction Variables" or "Natural Loop Construction" such that the loops were represented in the same form. Still I do not find a one-to-one link between the loop condition, body and end, and the BasicBlocks returned by the getHeader, getLoopLatch etc. My next strategy would be to modify the front-end, clang, and attach metadata to indicate whether the BasicBlock is part of the condition or of the body of the loop. I would very much appreciate if you could suggest an easier way to differentiate between the parts of the loop. Thank you, Alexandra -- View this message in context: http://old.nabble.com/Separate-loop-condition-and-loop-body-tp28512281p28512281.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
On May 10, 2010, at 8:43 AM, Xinfinity wrote:> Is it possible to get the list of BasicBlocks building the condition > of a > loop and the list of BasicBlocks that form the body?Based on my (limited) experience with Loop and LoopInfo, this isn't possible. (But don't take my word for it.)> My aim is to manipulate for loops, while and do-while loops unitary, > but I > did not find an easy way to do this.I think the problem here is that LLVM's CFG is low-level enough such that the distinction between the loop header expression and the loop body is lost. Why exactly do you need to identify the blocks that form the loop header expression? I'm wondering if you could find some workaround that doesn't require this... Trevor
On Mon, May 10, 2010 at 8:05 PM, Trevor Harmon <Trevor.W.Harmon at nasa.gov> wrote:> On May 10, 2010, at 8:43 AM, Xinfinity wrote: > >> Is it possible to get the list of BasicBlocks building the condition >> of a loop and the list of BasicBlocks that form the body? > > Based on my (limited) experience with Loop and LoopInfo, this isn't > possible. (But don't take my word for it.) > >> My aim is to manipulate for loops, while and do-while loops unitary, >> but I did not find an easy way to do this. > > I think the problem here is that LLVM's CFG is low-level enough such > that the distinction between the loop header expression and the loop > body is lost. > > Why exactly do you need to identify the blocks that form the loop > header expression? I'm wondering if you could find some workaround > that doesn't require this... >To me it looks like any basic block from the loop body with a successor not in the loop body is a BB "building the condition" (an "exit" block). If you already have the loop body, it should be pretty easy to find out about those nodes. cheers, Benoit
Reasonably Related Threads
- [LLVMdev] Separate loop condition and loop body
- [LLVMdev] Separate loop condition and loop body
- [LLVMdev] Separate loop condition and loop body
- [LLVMdev] Separate loop condition and loop body
- Propagation of debug information for variable into basic blocks.