<div dir="ltr"><div dir="ltr">There are a few ways to do this, but in general there is not an O(1) way to do this if your transform is doing arbitrary instruction insertion and removal.<div><br></div><div>The basic approach is to iterate the list, so this is O(bb length). `DominatorTree::dominates(Instruction*,Instruction*)` will do this for you. The next is to use OrderedBasicBlock (or OrderedInstructions for a whole function) to cache the instruction ordering.</div><div><br></div><div>Finally, I have this patch that I haven't found time to work on which caches the numbering in Instruction itself: <a href="https://reviews.llvm.org/D51664">https://reviews.llvm.org/D51664</a> Just needs a few days of work to make it happen.</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 7, 2019 at 9:46 AM PaweÅ‚ Bylica via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi,</div><div><br></div><div>Having two instructions in the same basic block is there a way to determine in what order they are in the basic block?</div><div><br></div><div>// PaweÅ‚<br></div></div>
_______________________________________________<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="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>