[LLVMdev] Inclusion of iostream affects devirtualization in release_35
Reid Kleckner
rnk at google.com
Wed Jan 7 08:38:31 PST 2015
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.
On Wed, Jan 7, 2015 at 12:03 AM, martin krastev <blu.dark at gmail.com> wrote:
> Hello,
>
> 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:
>
>
> #if BREAKAGE_ENSUES
> #include <iostream>
> #endif
>
> struct Base {
> virtual int foo() const = 0;
> };
>
> struct A : Base {
> int a;
>
> A(const int a)
> : a(a) {
> }
>
> int foo() const {
> return a;
> }
> };
>
> struct B : Base {
> const Base* b;
>
> B(const Base* const base)
> : b(base) {
> }
>
> int foo() const {
> return b->foo();
> }
> };
>
> const A a(42);
> const B b(&a);
>
> int main(int, char**) {
> return b.foo();
> }
>
>
> Is that a known issue, and if not, under what category should I file a
> ticket for it?
>
> Best regards,
> Martin
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150107/41a62013/attachment.html>
More information about the llvm-dev
mailing list