<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Dec 9, 2007, at 17:50, Gordon Henriksen wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">On Dec 3, 2007, at 17:59, pawel kunio wrote:<br><br><blockquote type="cite">Whoah, pretty strange I get neither of those. I'm using compiler <span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">from vs 2008 beta2 'orcas'. What compiler should I use to be more in sync with the one used by You for verification? btw, I had a deeper look into the Value class hierarchy and it seems that to remove all vtables there will be a need to flatten Instruction hierarchy with regard to the clone virtual method as well as Constant destroyConstant,isNullValue,replaceUsesOfWithOnConstant methods) and GlobalValue (isDeclaration method). Those as well as print and dump methods will probably be blocking the Value destructor from being de-virtualized.</span></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Anyway, please find the patch attached with the Value destructor <span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">virtualized temporarily and with added 'class' clause to friend Value declarations.</span></blockquote><br>Thanks Pawel! I've applied your patch as rev 44747 here:<br><br><a href="http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20071203/056105.html">http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20071203/056105.html</a><br></blockquote></div><div apple-content-edited="true"><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><br class="webkit-block-placeholder"></div><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">Since there are some other methods to devirtualize deeper in the class hierarchy, I wonder if it might make sense to write the dispatch once instead of repeating it several times. Here are some ideas off the top of my head…</div><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div><br class="webkit-block-placeholder"></div></span></span></span></span></span></div></span></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><span class="Apple-style-span" style="color: rgb(255, 0, 0); font-family: Courier; font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">// Dispatch to static methods.</span><br><span class="Apple-style-span" style="font-family: Courier; font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><font class="Apple-style-span" color="#0000FF">#define</font> NONVIRTUAL_DISPATCH1(V, F) \</span><br><span class="Apple-style-span" style="font-family: Courier; font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">       <font class="Apple-style-span" color="#0000FF">if</font> (Foo *W = dyn_cast<Foo>(V)) W->F(); \</span><br><span class="Apple-style-span" style="font-family: Courier; font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">  <font class="Apple-style-span" color="#0000FF">else if</font> (Bar *W = dyn_cast<Bar>(V)) W->F(); \</span><br><span class="Apple-style-span" style="font-family: Courier; font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">  <font class="Apple-style-span" color="#0000FF">else if</font> (Baz *W = dyn_cast<Baz>(V)) W->F();</span><br><br><br><span class="Apple-style-span" style="color: rgb(255, 0, 0); font-family: Courier; font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">// Dispatch to static methods.</span><br><span class="Apple-style-span" style="font-family: Courier; font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><font class="Apple-style-span" color="#0000FF">#define</font> NONVIRTUAL_DISPATCH2(V, F) \</span><br><span class="Apple-style-span" style="font-family: Courier; font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">       <font class="Apple-style-span" color="#0000FF">if</font> (Foo *W = dyn_cast<Foo>(V)) Foo::F(W); \</span><br><span class="Apple-style-span" style="font-family: Courier; font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">  <font class="Apple-style-span" color="#0000FF">else if</font> (Bar *W = dyn_cast<Bar>(V)) Bar::F(W); \</span><br><span class="Apple-style-span" style="font-family: Courier; font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">  <font class="Apple-style-span" color="#0000FF">else if</font> (Baz *W = dyn_cast<Baz>(V)) Baz::F(W);</span><br><br><br><span class="Apple-style-span" style="color: rgb(255, 0, 0); font-family: Courier; font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">// Dispatch to operator() overloads on a template operand.</span><br><span class="Apple-style-span" style="font-family: Courier; font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><font class="Apple-style-span" color="#0000FF">template</font> <<font class="Apple-style-span" color="#0000FF">typename</font> Algo></span><br><span class="Apple-style-span" style="font-family: Courier; font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><font class="Apple-style-span" color="#0000FF">void</font> NonvirtualDispatch3(Value *V) {</span><br><span class="Apple-style-span" style="font-family: Courier; font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">  Algo A;</span><br><span class="Apple-style-span" style="font-family: Courier; font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">  NonvirtualDispatch3(V, A);</span><br><span class="Apple-style-span" style="font-family: Courier; font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">};</span><br><br><span class="Apple-style-span" style="font-family: Courier; font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><font class="Apple-style-span" color="#0000FF">template</font> <<font class="Apple-style-span" color="#0000FF">typename</font> Algo></span><br><span class="Apple-style-span" style="font-family: Courier; font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><font class="Apple-style-span" color="#0000FF">void</font> NonvirtualDispatch3(Value *V, Algo &A) {</span><br><span class="Apple-style-span" style="font-family: Courier; font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">       <font class="Apple-style-span" color="#0000FF">if</font> (Foo *W = dyn_cast<Foo>(V)) A(W);</span><br><span class="Apple-style-span" style="font-family: Courier; font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">  <font class="Apple-style-span" color="#0000FF">else if</font> (Bar *W = dyn_cast<Bar>(V)) A(W);</span><br><span class="Apple-style-span" style="font-family: Courier; font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">  <font class="Apple-style-span" color="#0000FF">else if</font> (Baz *W = dyn_cast<Baz>(V)) A(W);</span></blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><span class="Apple-style-span" style="font-family: Courier; font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">};</span></blockquote><div apple-content-edited="true"><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><font class="Apple-style-span" face="Courier"></font></span></div><div><font class="Apple-style-span" face="'Lucida Grande'" size="3"><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="'Lucida Grande'" size="3"><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px;">I don't like promoting methods to classes, so </span><span class="Apple-style-span" style="white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><font class="Apple-style-span" face="Courier" size="3"><span class="Apple-style-span" style="font-size: 11px;">NovirtualDispatch3</span></font></span><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"> is initially unattractive to me. However, there are practical benefits.</span></font></div><div><font class="Apple-style-span" face="'Lucida Grande'" size="3"><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><br class="webkit-block-placeholder"></span></font></div><ul class="MailOutline"><li><span class="Apple-style-span" style="font-family: 'Lucida Grande'; "><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">It allows separate compilation by defining the </span><span class="Apple-style-span" style="white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><font class="Apple-style-span" face="Courier" size="3"><span class="Apple-style-span" style="font-size: 11px; ">operator()(Foo*)</span></font></span><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "> overload</span><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "> in </span><span class="Apple-style-span" style="white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><font class="Apple-style-span" face="Courier" size="3"><span class="Apple-style-span" style="font-size: 11px; ">Foo.c</span></font></span><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">. The declarations must be visible for an algorithm invoked from </span><span class="Apple-style-span" style="white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><font class="Apple-style-span" face="Courier" size="3"><span class="Apple-style-span" style="font-size: 11px;">Value</span></font></span><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">, though.</span></span></li><li><span class="Apple-style-span" style="font-family: 'Lucida Grande'; "><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">It can dispatch algorithms that take arguments by passing an </span><span class="Apple-style-span" style="white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><font class="Apple-style-span" face="Courier" size="3"><span class="Apple-style-span" style="font-size: 11px;">Algo</span></font></span><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "> instance using the second overload.</span></span></li><li><font class="Apple-style-span" face="'Lucida Grande'" size="3"><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px;">Overloads on the </span><span class="Apple-style-span" style="white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><font class="Apple-style-span" face="Courier" size="3"><span class="Apple-style-span" style="font-size: 11px;">V</span></font></span><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"> parameter could dispatch over subtypes.</span></font></li></ul><div><font class="Apple-style-span" face="'Lucida Grande'" size="3"><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><span class="Apple-style-span" style="font-family: 'Trebuchet MS'; font-size: 12px; white-space: normal; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; "><ul class="MailOutline"><li><font class="Apple-style-span" face="'Lucida Grande'" size="3"><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">These properties make it applicable for users of </span><span class="Apple-style-span" style="white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><font class="Apple-style-span" face="Courier" size="3"><span class="Apple-style-span" style="font-size: 11px;">Value</span></font></span><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">, not just its implementation.</span></font></li></ul><div><font class="Apple-style-span" face="'Lucida Grande'" size="3"><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><br class="webkit-block-placeholder"></span></font></div></span></span></font></div><div><font class="Apple-style-span" face="'Lucida Grande'" size="3"><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px;">All of these techniques can follow the class hierarchy automatically. In the first two cases, a base class will provide a default implementation. In the lattermost case, undefined overloads will fall back to the base class.</span></font></div><div><font class="Apple-style-span" face="'Lucida Grande'" size="3"><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><br class="webkit-block-placeholder"></span></font></div>— Gordon<br class="Apple-interchange-newline"></span></span></span></span></span></div></span> </div><br></body></html>