<div dir="ltr"><br><div>Thank you very much to you all. I got the idea. Only problem is now to relate the ID back to a specific IR instruction in case I want to trace back which ID an instruction corresponds to. I can either write the mapping on disk or augment the bitcode format to accommodate an ID field (may be).</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 8 May 2017 at 22:19, Daniel Berlin <span dir="ltr"><<a href="mailto:dberlin@dberlin.org" target="_blank">dberlin@dberlin.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Right.<div>As folks have told you, the following loop will always give the same instructions in the same order given the same input IR:<br><br><br>for (auto &BB : F)<br> for (auto &I : BB)<br><div class="gmail_extra"> Instruction *IPtr = &I;</div><div class="gmail_extra"><br></div><div class="gmail_extra">Thus, you only need to give them an id based on the order you see them.</div><div class="gmail_extra"><br></div><div class="gmail_extra">If you need something you can access outside of llvm as well, you could also rename each instruction to the id number using setName.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_quote">On Mon, May 8, 2017 at 10:12 PM, George Burgess IV via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span><span style="font-size:12.8px">> Isn't Instruction* a pointer to the instruction in memory? If so, it'll change across runs</span><div><span style="font-size:12.8px"><br></span></div></span><div><span style="font-size:12.8px">Correct, but none of this is meant to be stored across runs, so the actual address doesn't matter. You recompute the map every time your IR is loaded.</span></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_4938438940682760164h5">On Mon, May 8, 2017 at 7:34 PM, Dipanjan Das via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_4938438940682760164h5"><div dir="ltr"><br><div class="gmail_extra"><span><br><div class="gmail_quote">On 8 May 2017 at 18:14, Jonathan Roelofs <span dir="ltr"><<a href="mailto:jonathan@codesourcery.com" target="_blank">jonathan@codesourcery.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">An alternative way to do it, which would be less invasive and more upstreaming friendly, would be to implement this as an analysis pass.<br>
<br>
In the pass, calculate a map<Instruction*,ID>, and use that as the analysis result. Then query that result for the ID where you need it. If you've written the analysis correctly, then you'll always get the same IDs for the same instructions given the same input IR.<br></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="m_4938438940682760164m_4120571885645056546m_7197215919278991181m_-7522216622262952066m_-663593307792106280m_8276957317657551208HOEnZb"><font color="#888888">
</font></span></blockquote></blockquote></div><div class="gmail_extra"><br></div></span>Isn't Instruction* a pointer to the instruction in memory? If so, it'll change across runs.<span><br><br clear="all"><div><br></div>-- <br><div class="m_4938438940682760164m_4120571885645056546m_7197215919278991181m_-7522216622262952066m_-663593307792106280m_8276957317657551208gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><span><div><div dir="ltr"><p>Thanks & Regards,</p>
<div>Dipanjan</div></div></div></span></div></div>
</span></div></div>
<br></div></div><span>______________________________<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" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></span></blockquote></div><br></div></div>
<br>______________________________<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" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><span><div><div dir="ltr"><p>Thanks & Regards,</p>
<div>Dipanjan</div></div></div></span></div></div>
</div>