<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;">Hi Wan, <div><br></div><div>Have you measured the performance impact of your change (compile time) ?  </div><div><br></div><div>Thanks,</div><div>Nadav </div><div><br><div><div>On Oct 17, 2013, at 4:40 AM, Wan, Xiaofei <<a href="mailto:xiaofei.wan@intel.com">xiaofei.wan@intel.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div lang="EN-US" 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; 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="WordSection1" style="page: WordSection1;"><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);">Ping again.<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);">Owen, is it OK to submit?<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);">Wan Xiaofei<o:p></o:p></span></div><div><div style="border-style: solid none none; border-top-color: rgb(181, 196, 223); border-top-width: 1pt; padding: 3pt 0in 0in;"><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><b><span style="font-size: 10pt; font-family: Tahoma, sans-serif;">From:</span></b><span style="font-size: 10pt; font-family: Tahoma, sans-serif;"><span class="Apple-converted-space"> </span><a href="mailto:llvm-commits-bounces@cs.uiuc.edu">llvm-commits-bounces@cs.uiuc.edu</a> [<a href="mailto:llvm-commits-bounces@cs.uiuc.edu">mailto:llvm-commits-bounces@cs.uiuc.edu</a>]<span class="Apple-converted-space"> </span><b>On Behalf Of<span class="Apple-converted-space"> </span></b>Wan, Xiaofei<br><b>Sent:</b><span class="Apple-converted-space"> </span>Sunday, October 13, 2013 12:50 AM<br><b>To:</b><span class="Apple-converted-space"> </span>Owen Anderson<br><b>Cc:</b><span class="Apple-converted-space"> </span><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a> LLVM<br><b>Subject:</b><span class="Apple-converted-space"> </span>RE: [PATCH] [Review Request] Improve getVTList() in SelectionDAG<o:p></o:p></span></div></div></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p> </o:p></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;">Owen:<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;"> </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;">FoldingSet can implement similar concept, 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;">Patch updated<span class="Apple-converted-space"> </span><a href="http://llvm-reviews.chandlerc.com/D1127" style="color: purple; text-decoration: underline;"><span style="color: windowtext;">http://llvm-reviews.chandlerc.com/D1127</span></a><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;"> </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;">BTW, FoldingSet is a good data structure, but it copies many contents when implementing hash and cause a big performance penalty since it is wildly used in SelectionDAG; meanwhile the hash value is calculated many times for same object. Our profiling data shows it consume about ~3-~5% of total time in llc; We may need to optimize it.<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;"> </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;">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;">Wan Xiaofei<o:p></o:p></span></div><div><div style="border-style: solid none none; border-top-color: rgb(181, 196, 223); border-top-width: 1pt; padding: 3pt 0in 0in;"><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><b><span style="font-size: 10pt; font-family: Tahoma, sans-serif;">From:</span></b><span style="font-size: 10pt; font-family: Tahoma, sans-serif;"><span class="Apple-converted-space"> </span>Owen Anderson [<a href="mailto:resistor@mac.com" style="color: purple; text-decoration: underline;">mailto:resistor@mac.com</a>]<span class="Apple-converted-space"> </span><br><b>Sent:</b><span class="Apple-converted-space"> </span>Saturday, October 12, 2013 2:08 AM<br><b>To:</b><span class="Apple-converted-space"> </span>Wan, Xiaofei<br><b>Cc:</b><span class="Apple-converted-space"> </span><a href="mailto:llvm-commits@cs.uiuc.edu" style="color: purple; text-decoration: underline;">llvm-commits@cs.uiuc.edu</a><span class="Apple-converted-space"> </span>LLVM<br><b>Subject:</b><span class="Apple-converted-space"> </span>Re: [PATCH] [Review Request] Improve getVTList() in SelectionDAG<o:p></o:p></span></div></div></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p> </o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">OK, I can see that it works.  It seems like you’re basically implementing the same idiom as the existing FoldingSet class (<a href="http://llvm.org/docs/ProgrammersManual.html#llvm-adt-foldingset-h" style="color: purple; text-decoration: underline;">http://llvm.org/docs/ProgrammersManual.html#llvm-adt-foldingset-h</a>).  Can you see if you could make use of that rather than rolling your own solution?<o:p></o:p></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p> </o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">—Owen<o:p></o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p> </o:p></div><div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">On Oct 10, 2013, at 10:26 PM, Wan, Xiaofei <<a href="mailto:xiaofei.wan@intel.com" style="color: purple; text-decoration: underline;">xiaofei.wan@intel.com</a>> wrote:<o:p></o:p></div></div><p class="MsoNormal" style="margin: 0in 0in 12pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p> </o:p></p><div><p class="MsoNormal" style="margin: 0in 0in 12pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9pt;">Owen:<br><br>Thanks for your comments.<span class="apple-converted-space"> </span><br>Patch updated<span class="apple-converted-space"> </span><a href="http://llvm-reviews.chandlerc.com/D1127" style="color: purple; text-decoration: underline;">http://llvm-reviews.chandlerc.com/D1127</a><br><br>SDVTList SelectionDAG::getVTList(EVT VT1, EVT VT2) {<br> const EVT tmpVTs[2] = {VT1, VT2};<br> return getVTList(tmpVTs, 2);<br>}<br>How does the lifetime of this array work out?  It looks like SDVTListInfo captures the pointer to the EVT array, which was stack allocated.  After this method returns, you're going to have a dangling pointer in the SDVTListInfo.<br>[Xiaofei] Yes, tmpVTs is an array on the stack, but it is just used temporally to determine whether this SDVTList  exist in the DenseMap, it won't be referenced anymore after that.<br><br>SDVTList SelectionDAG::getVTList(const EVT *VTs, unsigned NumVTs) {<br> SDVTListInfo Key(VTs, NumVTs);<br> if (VTListMap.count(Key))<br>   return VTListMap[Key];<br><br> EVT *Array = Allocator.Allocate<EVT>(NumVTs);<br> std::copy(VTs, VTs + NumVTs, Array); -------------------------------------------------VTs is copied out to Array which will be stored in the DenseMap<br> SDVTList Result = makeVTList(Array, NumVTs);<br> Key.pVTs = Array; --------------------------------------------------VTs is not used any more.<br> VTListMap.insert(std::make_pair(Key, Result));<br><br> return Result;<br>}<br><br>Thanks<br>Wan Xiaofei<br><br>-----Original Message-----<br>From: Owen Anderson [<a href="mailto:resistor@mac.com" style="color: purple; text-decoration: underline;">mailto:resistor@mac.com</a>]<span class="apple-converted-space"> </span><br>Sent: Friday, October 11, 2013 1:30 AM<br>To: Wan, Xiaofei<br>Cc:<span class="apple-converted-space"> </span><a href="mailto:llvm-commits@cs.uiuc.edu" style="color: purple; text-decoration: underline;">llvm-commits@cs.uiuc.edu</a><span class="apple-converted-space"> </span>LLVM<br>Subject: Re: [PATCH] [Review Request] Improve getVTList() in SelectionDAG<br><br>Some feedback:<br><br><o:p></o:p></span></p><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9pt;">+  /// getEmptyKey() - A private constructor that returns an unknown<span class="apple-converted-space"> </span><br>+ that is  /// not equal to the tombstone key or SDVTListInfo().<br>+  static SDVTListInfo getEmptyKey() {<br>+    SDVTListInfo SDVTInfo;<br>+    SDVTInfo.NumVTs = 0;<br>+    return SDVTInfo;<br>+  }<br>+<br>+  /// getTombstoneKey() - A private constructor that returns an<span class="apple-converted-space"> </span><br>+ unknown that  /// is not equal to the empty key or SDVTListInfo().<br>+  static SDVTListInfo getTombstoneKey() {<br>+    SDVTListInfo SDVTInfo;<br>+    SDVTInfo.NumVTs = 0;<br>+    return SDVTInfo;<br>+  }<o:p></o:p></span></div><p class="MsoNormal" style="margin: 0in 0in 12pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9pt;"><br>I don't think this is a valid implementation of the DenseMapInfo callbacks.  getEmptyKey() and getTombstoneKey() have to return values that don't compare equal to each other.<br><br><o:p></o:p></span></p><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9pt;">+  const EVT pVTs[2] = {VT1, VT2};<br>+  return getVTList(pVTs, 2);<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: 9pt;"><br>How does the lifetime of this array work out?  It looks like SDVTListInfo captures the pointer to the EVT array, which was stack allocated.  After this method returns, you're going to have a dangling pointer in the SDVTListInfo.<br><br>-Owen<br><br><D1127.5.patch><o:p></o:p></span></div></div></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p> </o:p></div></div></div>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</div></blockquote></div><br></div></body></html>