As stated in an earlier email, I am working on getting break/continue to work correctly for my backend, but I ran into another issue with codegen and the CFG. It seems that code gen is not done based on the CFG, but rather on the block numbers, and the function call MachineFunction::RenumberBlocks doesn't renumber the blocks based on the CFG. So how can I modify the CFG so that when codegen occurs, it follows the graph and not just does a linear scan over the MachineBasicBlock vector? In the attached dot file, block 2 gets printed before block 3 and 5 and block 4 gets printed between blocks 3 and 5. This obviously is not what the CFG is saying it should be done. The code I'm using to do this transformation, which takes 2 & 4 and places them after block 5 is: MachineBasicBlock* newExitPath = findLowestNumSuccBB(root); pHigh->addSuccessor(newExitPath); root->removeSuccessor(newExitPath); root->CorrectExtraCFGEdges(*root->succ_begin(), NULL, false); pHigh->CorrectExtraCFGEdges(*pHigh->succ_begin(), newExitPath, false); newExitPath->moveAfter(pHigh); root->getParent()->RenumberBlocks(); So what am I doing wrong? Thanks, Micah Villmow Systems Engineer Advanced Technology & Performance Advanced Micro Devices Inc. 4555 Great America Pkwy, Santa Clara, CA. 95054 P: 408-572-6219 F: 408-572-6596 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20081013/13c37349/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: mftest_fc_for_break_or.dot Type: application/octet-stream Size: 2455 bytes Desc: mftest_fc_for_break_or.dot URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20081013/13c37349/attachment.obj>
On Oct 13, 2008, at 5:14 PMPDT, Villmow, Micah wrote:> As stated in an earlier email, I am working on getting break/ > continue to work correctly for my backend, but I ran into another > issue with codegen and the CFG. It seems that code gen is not done > based on the CFG, but rather on the block numbers, and the function > call MachineFunction::RenumberBlocks doesn’t renumber the blocks > based on the CFG. So how can I modify the CFG so that when codegen > occurs, it follows the graph and not just does a linear scan over > the MachineBasicBlock vector?It's not intended to work that way. The BranchFolding pass, which runs later, is responsible for rearranging things into a more reasonable order.> In the attached dot file, block 2 gets printed before block 3 and 5 > and block 4 gets printed between blocks 3 and 5. This obviously is > not what the CFG is saying it should be done. The code I’m using to > do this transformation, which takes 2 & 4 and places them after > block 5 is: > MachineBasicBlock* newExitPath = findLowestNumSuccBB(root); > pHigh->addSuccessor(newExitPath); > root->removeSuccessor(newExitPath); > root->CorrectExtraCFGEdges(*root->succ_begin(), > NULL, false); > pHigh->CorrectExtraCFGEdges(*pHigh->succ_begin(), > newExitPath, false); > newExitPath->moveAfter(pHigh); > root->getParent()->RenumberBlocks(); > > So what am I doing wrong? > > Thanks, > > > Micah Villmow > Systems Engineer > Advanced Technology & Performance > Advanced Micro Devices Inc. > 4555 Great America Pkwy, > Santa Clara, CA. 95054 > P: 408-572-6219 > F: 408-572-6596 > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20081013/46cbe475/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: mftest_fc_for_break_or.dot Type: application/octet-stream Size: 2455 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20081013/46cbe475/attachment.obj> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20081013/46cbe475/attachment-0001.html>
You don't have to run the branch folding pass, do you? Dan On Oct 13, 2008, at 8:27 PM, Dale Johannesen wrote:> > On Oct 13, 2008, at 5:14 PMPDT, Villmow, Micah wrote: > >> As stated in an earlier email, I am working on getting break/ >> continue to work correctly for my backend, but I ran into another >> issue with codegen and the CFG. It seems that code gen is not done >> based on the CFG, but rather on the block numbers, and the function >> call MachineFunction::RenumberBlocks doesn’t renumber the blocks >> based on the CFG. So how can I modify the CFG so that when codegen >> occurs, it follows the graph and not just does a linear scan over >> the MachineBasicBlock vector? > > It's not intended to work that way. The BranchFolding pass, which > runs later, is responsible for rearranging things into a more > reasonable order. > >> In the attached dot file, block 2 gets printed before block 3 and 5 >> and block 4 gets printed between blocks 3 and 5. This obviously is >> not what the CFG is saying it should be done. The code I’m using to >> do this transformation, which takes 2 & 4 and places them after >> block 5 is: >> MachineBasicBlock* newExitPath = findLowestNumSuccBB(root); >> pHigh->addSuccessor(newExitPath); >> root->removeSuccessor(newExitPath); >> root->CorrectExtraCFGEdges(*root->succ_begin(), >> NULL, false); >> pHigh->CorrectExtraCFGEdges(*pHigh->succ_begin(), >> newExitPath, false); >> newExitPath->moveAfter(pHigh); >> root->getParent()->RenumberBlocks(); >> >> So what am I doing wrong? >> >> Thanks, >> >> >> Micah Villmow >> Systems Engineer >> Advanced Technology & Performance >> Advanced Micro Devices Inc. >> 4555 Great America Pkwy, >> Santa Clara, CA. 95054 >> P: 408-572-6219 >> F: 408-572-6596 >> > <mftest_fc_for_break_or.dot> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20081013/cecfe3fa/attachment.html>
But, the branch folding pass, or whatever passes are supposed to reorder the blocks based on the CFG, are not doing so in this case. Otherwise there is no way that blocks 2 and 4 should be printing out before blocks 3 & 5. Renumber blocks just seems to reorder the values based on their pre-set block number, but when the CFG is modified these number should modified also to follow the new ordering, which is not occurring. ________________________________ From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Dale Johannesen Sent: Monday, October 13, 2008 5:28 PM To: LLVM Developers Mailing List Subject: Re: [LLVMdev] CFG modifcations and code gen On Oct 13, 2008, at 5:14 PMPDT, Villmow, Micah wrote: As stated in an earlier email, I am working on getting break/continue to work correctly for my backend, but I ran into another issue with codegen and the CFG. It seems that code gen is not done based on the CFG, but rather on the block numbers, and the function call MachineFunction::RenumberBlocks doesn't renumber the blocks based on the CFG. So how can I modify the CFG so that when codegen occurs, it follows the graph and not just does a linear scan over the MachineBasicBlock vector? It's not intended to work that way. The BranchFolding pass, which runs later, is responsible for rearranging things into a more reasonable order. In the attached dot file, block 2 gets printed before block 3 and 5 and block 4 gets printed between blocks 3 and 5. This obviously is not what the CFG is saying it should be done. The code I'm using to do this transformation, which takes 2 & 4 and places them after block 5 is: MachineBasicBlock* newExitPath = findLowestNumSuccBB(root); pHigh->addSuccessor(newExitPath); root->removeSuccessor(newExitPath); root->CorrectExtraCFGEdges(*root->succ_begin(), NULL, false); pHigh->CorrectExtraCFGEdges(*pHigh->succ_begin(), newExitPath, false); newExitPath->moveAfter(pHigh); root->getParent()->RenumberBlocks(); So what am I doing wrong? Thanks, Micah Villmow Systems Engineer Advanced Technology & Performance Advanced Micro Devices Inc. 4555 Great America Pkwy, Santa Clara, CA. 95054 P: 408-572-6219 F: 408-572-6596 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20081014/62772382/attachment.html>