Hi, I have a couple of questions about MachineBasicBlocks: - If I have a pointer to an MBB, is there an easy way to find which block that precedes it in the MachineFunction blocks list? (without iterating through all of the MF's basic blocks) - Does LLVM make any effort to ensure that MBB's predecessors and successors lists are semantically correct? For example, what happens if an MBB "falls through" into the next block, but the next block is not on its' successors list? thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140726/996abe40/attachment.html>
Hi, On 26 July 2014 09:04, Vadim Chugunov <vadimcn at gmail.com> wrote:> - If I have a pointer to an MBB, is there an easy way to find which block > that precedes it in the MachineFunction blocks list? (without iterating > through all of the MF's basic blocks)You should be able to construct a MachineFunction::iterator directly from your basic block and move backwards/forwards using that (E.g. "std::prev(MachineFunction::iterator(MyBB))" at its most basic).> - Does LLVM make any effort to ensure that MBB's predecessors and successors > lists are semantically correct?Yes. Within a pass you can usually save up the adjustments for later (depending on what support calls you make), but you need to maintain this information if you're modifying the block structure.> For example, what happens if an MBB "falls > through" into the next block, but the next block is not on its' successors > list?I think that shouldn't happen and would be a bug. Is this hypothetical, or do you have an example where we're doing this at the moment? Cheers. Tim.
Hi Vadim, On 2014-07-26 10:04, Vadim Chugunov wrote:> Hi, > I have a couple of questions about MachineBasicBlocks: > > - If I have a pointer to an MBB, is there an easy way to find which > block that precedes it in the MachineFunction blocks list? (without > iterating through all of the MF's basic blocks)You can use MachineBasicBlock's predecessors() method (or pred_begin() / pred_end()).> - Does LLVM make any effort to ensure that MBB's predecessors and > successors lists are semantically correct? For example, what > happens if an MBB "falls through" into the next block, but the next > block is not on its' successors list?This would be invalid. There is a MachineVerifier pass to check for such errors in the machine code.> thanks!-Manuel
On Sat, Jul 26, 2014 at 2:50 AM, Tim Northover <t.p.northover at gmail.com> wrote:> Hi, > > On 26 July 2014 09:04, Vadim Chugunov <vadimcn at gmail.com> wrote: > > - If I have a pointer to an MBB, is there an easy way to find which block > > that precedes it in the MachineFunction blocks list? (without iterating > > through all of the MF's basic blocks) > > You should be able to construct a MachineFunction::iterator directly > from your basic block and move backwards/forwards using that (E.g. > "std::prev(MachineFunction::iterator(MyBB))" at its most basic). > > > - Does LLVM make any effort to ensure that MBB's predecessors and > successors > > lists are semantically correct? > > Yes. Within a pass you can usually save up the adjustments for later > (depending on what support calls you make), but you need to maintain > this information if you're modifying the block structure. > > > For example, what happens if an MBB "falls > > through" into the next block, but the next block is not on its' > successors > > list? > > I think that shouldn't happen and would be a bug. Is this > hypothetical, or do you have an example where we're doing this at the > moment? >Hypothetical. I am trying to figure out what my code needs to be deal with. Sounds like this one would not be a concern then. thanks, Vadim -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140726/d5df1d56/attachment.html>
Seemingly Similar Threads
- [LLVMdev] Finding previous emitted instruction
- [LLVMdev] RFC: How to represent SEH (__try / __except) in LLVM IR
- [LLVMdev] [lldb-dev] RFC: LLVM should require a working C++11 <thread>, <mutex>, and <atomic>
- [LLVMdev] RFC: How to represent SEH (__try / __except) in LLVM IR
- [LLVMdev] Emit code for 'unreachable'