[LLVMdev] Inclusion of iostream affects devirtualization in release_35

Nick Lewycky
Wed, 07 Jan 2015 20:02:15 -0000

On 7 January 2015 at 08:38, Reid Kleckner <rnk at google.com> wrote:

> 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.
>

Yikes, that's a limitation right there isn't it. Should we have a PR or
is
there nothing for the optimizer can do?

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
>>
>>
>
> _______________________________________________
> 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/5619cdd0/attachment.html>