<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 7 January 2015 at 08:38, Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</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"><div>This isn't really devirtualization so much as global opt plus basic constant propagation. My theory is that iostream injects static initializers for std::cout / std::cerr into your TU. LLVM's global opt pass will fail when those are present.</div></div></blockquote><div><br></div><div>Yikes, that's a limitation right there isn't it. Should we have a PR or is there nothing for the optimizer can do?</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5">On Wed, Jan 7, 2015 at 12:03 AM, martin krastev <span dir="ltr"><<a href="mailto:blu.dark@gmail.com" target="_blank">blu.dark@gmail.com</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="h5"><div dir="ltr">Hello,<div><br></div><div>I've stumbled upon the following behavior in branches/release_35 (as of 218689) under ubuntu 14.04 LTS amd64: whenever I include the (system-wise) gnu iostream header, clang++ stops devirtualizing the following code:</div><div><br></div><div><br></div><div><div>#if BREAKAGE_ENSUES</div><div>#include <iostream></div><div>#endif</div><div><br></div><div>struct Base {</div><div><span style="white-space:pre-wrap">   </span>virtual int foo() const = 0;</div><div>};</div><div><br></div><div>struct A : Base {</div><div><span style="white-space:pre-wrap">   </span>int a;</div><div><br></div><div><span style="white-space:pre-wrap">  </span>A(const int a) </div><div><span style="white-space:pre-wrap"> </span>: a(a) {</div><div><span style="white-space:pre-wrap"> </span>}</div><div><br></div><div><span style="white-space:pre-wrap">       </span>int foo() const {</div><div><span style="white-space:pre-wrap">                </span>return a;</div><div><span style="white-space:pre-wrap">        </span>}</div><div>};</div><div><br></div><div>struct B : Base {</div><div><span style="white-space:pre-wrap">      </span>const Base* b;</div><div><br></div><div><span style="white-space:pre-wrap">  </span>B(const Base* const base)</div><div><span style="white-space:pre-wrap">        </span>: b(base) {</div><div><span style="white-space:pre-wrap">      </span>}</div><div><br></div><div><span style="white-space:pre-wrap">       </span>int foo() const {</div><div><span style="white-space:pre-wrap">                </span>return b->foo();</div><div><span style="white-space:pre-wrap">      </span>}</div><div>};</div><div><br></div><div>const A a(42);</div><div>const B b(&a);</div><div><br></div><div>int main(int, char**) {</div><div><span style="white-space:pre-wrap"> </span>return b.foo();</div><div>}</div></div><div><br></div><div><br></div><div>Is that a known issue, and if not, under what category should I file a ticket for it?</div><div><br></div><div>Best regards,</div><div>Martin</div></div>
<br></div></div>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">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>
<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></div>