Hacker Newsnew | past | comments | ask | show | jobs | submit | nickwanninger's commentslogin

At the level that LLVM's LTO operates, no information about classes or objects is left, so LLVM itself can't really devirtualize C++ methods in most cases


You appear to be correct. Clang does not devirtualize in LTO, but GCC does. Personally I consider this very strange.

     $ cat animal.h cat.cpp main.cpp
    // animal.h
    
    #pragma once
    
    class animal {
     public:
      virtual ~animal() {}
      virtual void speak() = 0;
    };
    
    animal& get_mystery_animal();
    // cat.cpp
    
    #include "animal.h"
    #include <cstdio>
    
    class cat final : public animal {
    public:
      ~cat() override{}
      void speak() override{
        puts("meow");
      }
    };
    
    static cat garfield{};
    
    animal& get_mystery_animal() {
      return garfield;
    }
    // main.cpp
    
    #include "animal.h"
    
    int main() {
      animal& a = get_mystery_animal();
      a.speak();
    }
     $ make clean && CXX=clang++ make -j && objdump --disassemble=main -C lto_test
    rm -f *.o lto_test
    clang++ -c -flto -O3 -g cat.cpp -o cat.o
    clang++ -c -flto -O3 -g main.cpp -o main.o
    clang++ -flto -O3 -g cat.o main.o -o lto_test
    
    lto_test:     file format elf64-x86-64
    
    
    Disassembly of section .init:
    
    Disassembly of section .plt:
    
    Disassembly of section .plt.got:
    
    Disassembly of section .text:
    
    00000000000011b0 <main>:
        11b0: 50                    push   %rax
        11b1: 48 8b 05 58 2e 00 00  mov    0x2e58(%rip),%rax        # 4010 <garfield>
        11b8: 48 8d 3d 51 2e 00 00  lea    0x2e51(%rip),%rdi        # 4010 <garfield>
        11bf: ff 50 10              call   *0x10(%rax)
        11c2: 31 c0                 xor    %eax,%eax
        11c4: 59                    pop    %rcx
        11c5: c3                    ret
    
    Disassembly of section .fini:
     $ make clean && CXX=g++ make -j && objdump --disassemble=main -C lto_test|sed -e 's,^,    ,'
    rm -f *.o lto_test
    g++ -c -flto -O3 -g cat.cpp -o cat.o
    g++ -c -flto -O3 -g main.cpp -o main.o
    g++ -flto -O3 -g cat.o main.o -o lto_test
    
    lto_test:     file format elf64-x86-64
    
    
    Disassembly of section .init:
    
    Disassembly of section .plt:
    
    Disassembly of section .plt.got:
    
    Disassembly of section .text:
    
    0000000000001090 <main>:
        1090: 48 83 ec 08           sub    $0x8,%rsp
        1094: 48 8d 3d 75 2f 00 00  lea    0x2f75(%rip),%rdi        # 4010 <garfield>
        109b: e8 50 01 00 00        call   11f0 <cat::speak()>
        10a0: 31 c0                 xor    %eax,%eax
        10a2: 48 83 c4 08           add    $0x8,%rsp
        10a6: c3                    ret
    
    Disassembly of section .fini:


I think this is a bug. There's dedicated metadata that's supposed to end up on the indirect call to list the possible targets and when that list of possible targets is this short it should be turning into a switch over concrete targets. Don't have time to dig into the IR now but it might be worth posting to the github llvm issues.


What if you add -fwhole-program-vtables on clang?


?


It looks like threads.net is going to be a web version -- though it isn't very clear how useful it will be.


Lucky for them, it's a fully custom OS that doesn't follow the standard :)


They don't make the compiler. GCC in very many places substitutes standard library names with intrinsics for the purposes of optimization or static analysis. I'm not aware of it doing so for ssize, but in principle this is a bad idea.


Not long till can we have a GB of floppys on one table. Imagine!


Likely that it supports the Supervisor execution environment from the riscv spec [1]. This means it can run the typical ring 0 and ring 3 for kernelspace and userspace respectively, and importantly the board supports virtual memory.

[1] https://riscv.org/wp-content/uploads/2017/05/riscv-privilege...


From the article: "New York Public Radio's investment in Pocket Casts was made possible, in part, by Cynthia King Vance and a grant from Carnegie Corporation of New York."

I don't think it was from donations, but I could be wrong


You can't donate to NPR (at least, not easily)...

You can argue that donations to local NPR stations helps free up revenue for NPR the organization, but donations don't directly translate in to anything that NPR does.


Note the phrase "in part".


I think they mean to say "being bloated like an IDE is slow, here's how to not be slow because of bloat". Or at least thats what I got out of it


Do you rebind your caps lock to escape? That's what I did, and it's become second nature at this point.


Yep I did that. I still often fatfinger the brightness and other things. It is corporate one, I have my old macbook air that works just as fine.


"Joins" isn't in the thesaurus for "was bought by"


Separate but related events?


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: