<div dir="ltr">Hi Matthias,<div><br></div><div>Sorry, my original question may have been ambiguously formulated.</div><div>I would like a range that handle any of those two cases transparently so that I can simply iterate without having to handle two different cases.</div><div><br></div><div>Today we can build an InstIterator that, for a given set of BB, will iterate over all of the instructions in each of them. This almost match my need except that when I am in the BB that contains the "begin" instruction I need to start from that one, and when I am in the BB that contains the "end" instruction I need to stop right before.</div><div>In addition, I need to build that list of BB from the DomTree and PostDomTree (Ideally I don't need the PostDomTree, maybe I can simply iterate on all BB dominated by the entry until I reach the exit instruction, which is guaranteed to finish thanks to the post-dominance property?).</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 9, 2018 at 1:00 PM, mbraun <span dir="ltr"><<a href="mailto:mbraun@apple.com" target="_blank">mbraun@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div>Within a basic block this is just normal iterator usage/manipulation:</div><div><br></div>for (instr : llvm::make_range(FromInstructi<wbr>on.getIterator(), ToInstruction.getIterator())) { ... }<div><br></div><div>Use std::next() on ToInstruction.getIterator() if you want it included.</div><div><br></div><div>- Matthias<br><div><br><blockquote type="cite"><div><div class="m_-1839726500470665989h5"><div>On Apr 9, 2018, at 10:04 AM, Alexandre Isoard via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="m_-1839726500470665989m_7309095955252804875Apple-interchange-newline"></div></div><div><div><div class="m_-1839726500470665989h5"><div dir="ltr">Hello,<div><br></div><div>Is there an iterator to iterate over a "range" of instructions in a Function?</div><div><br></div><div>"range" meaning from an instruction::iterator up to an other instruction::iterator which either:</div><div>- point to instructions in the same basic block (the first one first, second one second)</div><div>- point to instructions in different basic block (the BB of the first dominate the BB of the second, and the BB of the second post-dominate the BB of the first)</div><div><br></div><div>I'm not sure if I can trick InstIterator into doing that for me (with a custom BB type?).<br clear="all"><div><br></div>-- <br><div class="m_-1839726500470665989m_7309095955252804875gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><b>Alexandre Isoard</b><br></div></div>
</div></div></div></div>
______________________________<wbr>_________________<br>LLVM Developers mailing list<br><a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br></div></blockquote></div><br></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="m_-1839726500470665989gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><b>Alexandre Isoard</b><br></div></div>
</div></div>