4 ms·
Gosh, I really wish GCC had more/better documentation. Especially big picture stuff. E.g., I would like to know what register allocation algorithms it uses (and
by cptwunderlich 4y ago
Gosh, I really wish GCC had more/better documentation. Especially big picture stuff.
E.g., I would like to know what register allocation algorithms it uses (and how certain details are handled), but looking at that code I noped out...
- astrange 4y agoYou can read GCC Summit presentations for things like that. The register allocator is called IRA/LRA. It used to have a ball of mud called reload that isn’t worth understanding because it doesn’t make much sense. GCC’s code style is strange because the original authors wanted to make it look like Lisp for some reason.
- touisteur 4y agoErr I always thought it looked strange because it was in C with classes before or after some holy war. While gcc (and in general compiler) plugins are some of the most interesting tech enablers (be it for fuzzing,, static analysis, or runtime checks injection) 'People competently maintaining gcc plugins' (a sect I'm not a part anymore, thank dog) are amongst the most patient, devoted, unsung angels of this world.
- astrange 4y agoIt’s in C++ now. The weird spacing and functions ending in _p are Lispisms. It’s also garbage collected so it’s still not “normal” C++ but neither is LLVM. Not sure about the plugin API, but C++ is basically impossible to use with plugins because it’s so hard to keep ABI contracts, so it might not have changed.
- UncleEntity 4y agoIsn’t the compiler the one who makes the ABI contract? And I’ve seen _p and friends all over the place usually to differentiate between a pointer and, umm, not pointer. I thought it was a C++ism to be honest.
- astrange 4y agoC++ has things like the fragile base class problem meaning you can accidentally break it easily. There's issues with throwing exceptions across different libraries on some platforms (maybe just Windows?) but I forget the reason why. p is short for predicate.
- pjmlp 4y agoFragile base class problem affects all languages that offer some kind of inheritance, not only C++.
- valleyer 4y agoYou are of course correct in a broad sense. However, when the discussion already mentions "ABI contracts", they're probably referring specifically to the "fragile binary interface problem" (especially regarding member field access), which does not affect all languages that offer inheritance. As the Wikipedia article mentions, this more specific problem is (confusingly) often referred to just as the "fragile base class problem". https://en.wikipedia.org/wiki/Fragile_binary_interface_problem https://en.wikipedia.org/wiki/Fragile_binary_interface_probl...
- pjmlp 4y agoIt still affects all compiled languages that offer inheritance, and OOP ABIs like COM.
- valleyer 4y agoMaybe I'm still misunderstanding you, but (modern) Objective-C is an example of a compiled language without the fragile base class ABI problem. (It pays for this with extra indirection at runtime, of course: ivar accesses must first look up their runtime-resolved offset.)
- touisteur 4y agoWell you basically have to compile the plugins against your gcc's headers anyway, and they're gpl by default (same as wireshark dissectors iirc). No the pain is all the churn on gcc internals and in plugin APIs over the years. You basically become an ifdef monkey and end up testing myriads of gcc versions...
- iib 4y agoMaybe the lispism are Stallman's legacy. He is a great lisp proponent after all.
- chrisseaton 4y agoIt uses something they call IRA and LRA on the RTL representation. But bottom line is: it's graph colouring. https://gcc.gnu.org/onlinedocs/gccint/RTL-passes.html https://gcc.gnu.org/onlinedocs/gccint/RTL-passes.html There's really quite a lot of documentation and published papers when you actually look: https://github.com/gcc-mirror/gcc/blob/751f306688508b08842d0ab967dee8e6c3b91351/gcc/ira.cc#L21-L363 https://github.com/gcc-mirror/gcc/blob/751f306688508b08842d0...
- Analemma_ 4y agoThis might be less true now, but for a long time gcc's code was terrible and undocumented on purpose. rms wanted it that way, to make it harder for it to be forked or EEE'd by corporations. Whether that was a good plan is up for debate, but there you go.
- WalterBright 4y agoPeople say that dmd's backend is terrible and undocumented, but I don't know what they're talking about: https://github.com/dlang/dmd/tree/master/src/dmd/backend https://github.com/dlang/dmd/tree/master/src/dmd/backend
- mhh__ 4y agoLLVM: Lots of documentation for frontend authors, not so much for backend stuff. GCC: Lots of documentation for backend authors, actively made difficult to being used for frontends for many years (although things have improved dramatically)
- est31 4y agoHow have things evolved for LLVM backend authors? Has it improved too?
- pif 4y ago> I would like to know what register allocation algorithms it uses I'm wondering why you'd like to know. If it is just for your curiosity, that's very good. If you want to participate in the compiler development effort, hat tip! But if you are thinking about tuning your code to such an internal detail, please don't! Coding to an implementation, rather than an interface, is never a good idea.