<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Sep 25, 2014, at 2:03 PM, Quentin Colombet <<a href="mailto:qcolombet@apple.com">qcolombet@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">I guess you want to do that after register allocation.<div>If that is the case, yes, you have to track the information by your self. You can use the register scavenger for an example of how to do that (RegisterScavenging.cpp).</div><div><br></div><div>If you do that before register allocation, you can use the LiveInterval information or directly the MachineRegisterInfo::getVRegDef (or something like that, I haven’t check the exact name).</div><div><br></div><div>-Quentin</div><div><div><div>On Sep 25, 2014, at 11:02 AM, cheng-chih yang <<a href="mailto:chad.yang@gmail.com">chad.yang@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div>Thanks Quentin. I'm trying to examine from the operands of the return instruction, and then to get the last assignment of those. </div></div></blockquote></div></div></div></blockquote><div><br></div><div>Also, note that the last assignment may not be unique, e.g.,</div><div>if (…)</div><div>  x = …</div><div>else</div><div>  x = …</div><div>return x</div><div><br></div><div>That means you may need is a reaching-def algorithm.</div><div>A complete implementation is available in AArch64CollectLOH.cpp, however, I think you’d better specialize a reaching-def algorithm to your case as it has some nice simplifications (e.g., your uses are always in exit basic block).</div><div><br></div><div>-Quentin </div><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><div><blockquote type="cite"><div dir="ltr"><div>I thought use_iterator/reg_iterator may suit better than just loop through the machine basicblock in the reverse order.<br><br></div>Cheng-Chih<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 25, 2014 at 1:51 PM, Quentin Colombet <span dir="ltr"><<a href="mailto:qcolombet@apple.com" target="_blank">qcolombet@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">Hi Cheng-Chih,<div><br><div><span class=""><div>On Sep 25, 2014, at 9:14 AM, Yang, Cheng-Chih <<a href="mailto:Cheng-Chih.Yang@amd.com" target="_blank">Cheng-Chih.Yang@amd.com</a>> wrote:</div><br><blockquote type="cite"><div link="blue" vlink="purple" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" lang="EN-US"><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">Hi folks,<u></u><u></u></div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">I would like to find out the machine instructions that use some given registers in the reverse order, and I came across these iterators (use_iterator/reg_iterator). However, there are two things I noticed:<u></u><u></u></div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">1) These iterators seem to traverse the machine function a bit differently from what I get from the machine function dump. In other words, the use_iterator list is not constructed in the same order as the machine function?</div></div></blockquote><div><br></div></span><div>Yes, the use_iterator list is not constructed in the same order as the machine function.</div><span class=""><br><blockquote type="cite"><div link="blue" vlink="purple" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" lang="EN-US"><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"> Maybe from the order that DAG is constructed?</div></div></blockquote><div><br></div></span>No, this is not the case either.</div><div>The list is constructed via calls to MachineInstr::setReg (which calls MachineRegisterInfo::addRegOperandToUseList if you are interested by the details), which could basically occur anywhere in the backend.</div><div>That said, the main users of this interface is the VirtRegMap pass, which walks through the function and set the register along the way. Therefore, most of the use_iterator should be in the order you want, but not all and more importantly, we do not ensure that this ordering is fulfilled.<span class=""><br><br><blockquote type="cite"><div link="blue" vlink="purple" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" lang="EN-US"><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"><u></u><u></u></div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">2) Is there a way to go backward with these two iterators? For example, from use_end() to use_begin() with some decrement operator?</div></div></blockquote><div><br></div></span>AFAIK, no, because we did not need so far to traverse them in a specific order.</div><div><br></div><div>What are you trying to achieve?</div><div><br></div><div>Cheers,</div><div>-Quentin<br><blockquote type="cite"><div link="blue" vlink="purple" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" lang="EN-US"><span class=""><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"><u></u><u></u></div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">I was wondering if 1) and 2) are true or just there’s something I missed.<u></u><u></u></div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">Thanks!<u></u><u></u></div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">Cheng-Chih<u></u><u></u></div></span>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu" style="color:purple;text-decoration:underline" target="_blank">LLVMdev@cs.uiuc.edu</a><span> </span>        <a href="http://llvm.cs.uiuc.edu/" style="color:purple;text-decoration:underline" target="_blank">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" style="color:purple;text-decoration:underline" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a></div></blockquote></div><br></div></div><br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu/" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div></div>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></div><br></body></html>