<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;">Xiaoyi,<div><br></div><div>Thanks for doing this! I think it's critical, not just for debug information, but for the many people who have started using pre-RA-sched=source. This looks more efficient and maintainable to me than the previous approach.</div><div><br></div><div>Preserving the order for everything except a certain class of nodes (e.g. constants) make DAG serialization straightforward. It just needs to  insert copies in rare cases, but won't need to find an optimal order. I'm particularly happy that we can remove uncertainty from the IR->MI conversion. It will be much easier to debug and write tests.</div><div><br></div><div>My only concern is merge conflicts in out-of-tree <target>ISelLowering and <target>ISelDAGToDAG. I personally don't think it will be too bad, since, as Nadav suggested, it's just a mechanical process of converting DebugLoc definitions:</div><div><br></div><div>DebugLoc dl = N->getDebugLoc()</div><div>-></div><div>SDLoc dl(N);</div><div><br></div><div>The getMachineNode call sites themselves should rarely need to change.</div><div><br></div><div>Also, we just had a significant API change in this area less than 2 weeks ago. It's a good time to make this change and do it right once and for all.</div><div><br></div><div>But it will be a giant diff. If you think that the changes will be too much, or if anyone else is concerned about merge conflicts, we can consider supporting a backward compatible API.</div><div><br></div><div>-Andy</div><div><br><div><div>On Apr 29, 2013, at 4:48 PM, "Guo, Xiaoyi" <<a href="mailto:Xiaoyi.Guo@amd.com">Xiaoyi.Guo@amd.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div lang="EN-US" link="blue" vlink="purple" style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="Section1" style="page: Section1;"><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);">Hi,<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);">We’ve recently encountered a problem in our compiler where the line number in debug info jumps back and force even at O0. This is caused by DAG node ordering not being properly kept during legalization and instruction selection. There are still uncaught cases after applying the patch mentioned here.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);">So I have decided to implement the approach suggested by Andy as below. i.e. maintain the node ordering as a field inside the DAG node and force anyone creating the DAG node to provide the ordering. When new DAG nodes are created inside DAG builder, DAG builder maintains the ordering of the current instruction being processed and provide that ordering to the DAG node creating routine. When new DAG nodes are created after DAG builder, e.g., during legalization, the original node’s ordering would be transferred to the new node.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);">Since it’s going to involve a lot of changes, I’d like to get feedback on the idea and the interface changes before I make changes to all the call sites.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);">Attached is a diff of the first batch of changes, which includes interface changes: a new wrapper class, new fields, interface changes to SelectionDAG::getXXX() functions.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);">Your feedback would be appreciated.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);">Thanks,<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);">Xiaoyi<o:p></o:p></span></div><div><p style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><br><br>    From: Andrew Trick <<a href="mailto:atrick@apple.com" style="color: purple; text-decoration: underline;">atrick@apple.com</a>><br>    <br>    Subject: Re: [PATCH] Propagate DAG node ordering during legalization and instruction selection<br>    <br>    Date: March 20, 2013 12:01:48 AM PDT<br>    <br>    To: Justin Holewinski <<a href="mailto:justin.holewinski@gmail.com" style="color: purple; text-decoration: underline;">justin.holewinski@gmail.com</a>><br>    <br>    Cc: llvm-commits <<a href="mailto:llvm-commits@cs.uiuc.edu" style="color: purple; text-decoration: underline;">llvm-commits@cs.uiuc.edu</a>><br>    <br><br><br>    On Mar 19, 2013, at 1:17 PM, Justin Holewinski <<a href="mailto:justin.holewinski@gmail.com" style="color: purple; text-decoration: underline;">justin.holewinski@gmail.com</a>> wrote:<br><br><br>        Updated patch attached.<br>        <br>        <br>        I've addressed the CSE during legalization issue.  Now ordering is only propagated if the new node does not have an ordering (is zero), or has an ordering that is greater than the replaced node.<br>        <br>        <br>        As for compile time, I think I may have had some other machine interference in the 8% figure.  I can't reproduce that now, and both LLVM unit tests and LNT are not showing any statistically significant differences.  I see some variation across runs in LNT, but it looks to be machine noise as I see both regressions and improvements in different benchmarks in different runs.  I see +/- 0.5% in the unit tests, but that goes both ways.  Both tests use release+asserts build.<br>        <br><br><br>    Your patch looks fine but doesn't go far enough. I'd like to add an IROrder field to SDNode (eventually we might be able to make it redundant with NodeId, although there would be temporary points at which nodes have to share an IROrder). That would remove any concerns about the compile-time of potentially frequent DenseMap lookup. But I really want to do it to help ensure that IROrder remains present and valid as a topological order. Then we don't need a "source order" scheduler at all, which would be really great. Just emit MIs for the selected nodes in place, and break some physreg interferences.<br><br>    Ideally, anyone who creates an SDNode needs to track down the IROrder. Rather than propagating IROrder when we replace all uses, we would do it when we morph or CSE the node, similar to DebugLoc. Ensuring topological order is another aspect of the problem that can be dealt with later.<br><br>    It's a big infrastructure project. But if you find any part of this plan will help you, progress toward that goal is welcome.<br><br>    -Andy<br><br><br>        On Tue, Mar 19, 2013 at 1:07 PM, Justin Holewinski <<a href="mailto:justin.holewinski@gmail.com" style="color: purple; text-decoration: underline;">justin.holewinski@gmail.com</a>> wrote:<br>        <br><br>            On Tue, Mar 19, 2013 at 12:47 PM, Justin Holewinski <<a href="mailto:justin.holewinski@gmail.com" style="color: purple; text-decoration: underline;">justin.holewinski@gmail.com</a>> wrote:<br>            <br><br><br>                On Tue, Mar 19, 2013 at 2:26 AM, Evan Cheng <<a href="mailto:evan.cheng@apple.com" style="color: purple; text-decoration: underline;">evan.cheng@apple.com</a>> wrote:<br>                <br><br><br><br>                    Sent from my iPad<br><br>                    On Mar 18, 2013, at 2:02 PM, Justin Holewinski <<a href="mailto:justin.holewinski@gmail.com" style="color: purple; text-decoration: underline;">justin.holewinski@gmail.com</a>> wrote:<br>                    <br>                    <br><br>                    Compile-time impact is negligible for a release build on the unit tests.  There is about an 8% impact with assertions enabled.<br><br><br>                    Unit tests are much too small for measuring compile time. 8% for assertion build is massive. Why are there such large discrepancy?<br><br><br>                I've been trying to get measurements from LNT, but I'm getting too much run-to-run variation.  A few benchmarks show significant changes (both positive and negative), but the affected benchmarks are diffe<o:p></o:p></span></p></div><table class="MsoNormalTable" border="0" cellpadding="0"><tbody><tr><td style="padding: 0.75pt;"></td></tr></tbody></table><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p> </o:p></div></div><span><DAGIROrder.1.diff></span>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu" style="color: purple; text-decoration: underline;">LLVMdev@cs.uiuc.edu</a><span class="Apple-converted-space"> </span>        <a href="http://llvm.cs.uiuc.edu/" style="color: purple; text-decoration: underline;">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" style="color: purple; text-decoration: underline;">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a></div></blockquote></div><br></div></body></html>