Hi, I need to do an inverse-depth-first iteration over the basic blocks in a machine function (i.e. starting from the last block and following predecessor edges) for a liveness analysis I'm writing. idf_iterator seems like it's almost the class I need, but it starts at the first block in the function at present, rather than the last one (because of the specialisiation of GraphTraits for Inverse<MachineFunction*> - getEntryNode returns mf->front()). That seems odd to me - you can only ever get to the first block with it (incrementing the iterator once yields idf_end(mf), and there's no decrement operation). Is this behaviour intentional? If it is I'll need to write some inverse iteration functions myself. Is there a recommended way to find the final block (the one with successors={}) in a machine function? (will mf->back() always return it?) Thanks, Lang.
On 2007-03-18, at 03:22, Lang Hames wrote:> Is there a recommended way to find the final block (the one with > successors={}) in a machine function?This isn't a property of the CFG in the general case. However, the UnifyFunctionExitNodes transformation/analysis provides it. From getAnalysis<UnifyFunctionExitNodes>().getReturnBlock(), you can visit the basic block predecessors recursively. — Gordon -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20070318/ec0bc472/attachment.html>
On 2007-03-18, at 09:54, Gordon Henriksen wrote:> On 2007-03-18, at 03:22, Lang Hames wrote: > >> Is there a recommended way to find the final block (the one with >> successors={}) in a machine function? > > This isn't a property of the CFG in the general case. However, the > UnifyFunctionExitNodes transformation/analysis provides it. From > getAnalysis<UnifyFunctionExitNodes>().getReturnBlock(), you can > visit the basic block predecessors recursively.Oh, MachineBB. Sorry; don't have an answer for you. — Gordon
On Sun, 18 Mar 2007, Lang Hames wrote:> I need to do an inverse-depth-first iteration over the basic blocks in > a machine function (i.e. starting from the last block and following > predecessor edges) for a liveness analysis I'm writing.As Gordon mentioned, there isn't a trivial way to do this, as there isn't a single exit node in the MBB CFG.> idf_iterator seems like it's almost the class I need, but it starts at > the first block in the function at present, rather than the last one > (because of the specialisiation of GraphTraits for > Inverse<MachineFunction*> - getEntryNode returns mf->front()). That > seems odd to me - you can only ever get to the first block with it > (incrementing the iterator once yields idf_end(mf), and there's no > decrement operation).That seems odd to me too. It sounds like Inverse<MF*> should be removed. -Chris -- http://nondot.org/sabre/ http://llvm.org/
Reasonably Related Threads
- [LLVMdev] idf_iterator and MachineFunctions
- [LLVMdev] idf_iterator and MachineFunctions
- [LLVMdev] Walking all the predecessors for a basic block
- [LLVMdev] Walking all the predecessors for a basic block
- [LLVMdev] Walking all the predecessors for a basic block