Ziqiang Patrick Huang via llvm-dev
2015-Aug-17 21:26 UTC
[llvm-dev] Inserting a new MachineBasicBlock between two existing MachineBasicBlocks
Hi all, Suppose I have two basicblock A->B, and I wanted to insert C between them so that A->B->C. By looking at MachineBasicBlock::SplitCriticalEdge, I did following similar steps: MachineBasicBlock *B = MF.CreateMachineBasicBlock(); MF.insert(std::next(MachineFunction::iterator(A)), B); LIS->insertMBBInMaps(B); LIS->getSlotIndexes()->insertMBBInMaps(B); But when I try to add the new basicblock into SlotIndexes, it fails at the assertion. assert(unsigned(mbb->getNumber()) == MBBRanges.size() && "Blocks must be added in order"); So I thought maybe I should add it at the end of the function, so I tried MF.insert(MF.end(), B), but it still fails, so I'm wondering what's the right way to do it. I'm doing it at MachineScheduler Pass. Thanks in Advance Patrick -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150817/7920a7f2/attachment.html>