Continuity problems
Continuity problems
Posted Mar 22, 2012 21:18 UTC (Thu) by HelloWorld (guest, #56129)In reply to: Continuity problems by james_ulrich
Parent article: GCC celebrates 25 years with the 4.7.0 release
The GCC code base is very hard to read as-is and moving it to a language that is notorious for being hard to read and understand will not make things any better.The GCC code base is actually a perfect example of things being convoluted because of missing functionality in the C language. C++, when used in a sensible way, is a way to fix this.
Posted Mar 22, 2012 22:05 UTC (Thu)
by james_ulrich (guest, #83666)
[Link] (4 responses)
The decision to go with C++ seems (to me, an outside observer) to have been driven firstly by some people (I remember Ian Lance Taylor's name, but there where others pushing) "because I like to code in C++", rather than there being a pressing needed feature that would make the code clearer.
Posted Mar 22, 2012 23:30 UTC (Thu)
by elanthis (guest, #6227)
[Link] (1 responses)
Recompiling existing crappy C code with a C++ compiler does no such thing. It may very well provide the tools to rewrite that functions in a readable, sane way that C cannot easily do.
The one clear winner in C++ is data structures and templates. I cannot stress the importance of that enough.
The second you have to write a data structure that uses nothing but void* elements, or which has to be written as a macro, or which has to be copied-and-pasted for every different element type, you have a serious problem.
GCC is a heavy user of many complex data structures, many of which are written as macros. Compare this to the LLVM/Clang codebase, where such data structures are written once in clean, readable, testable, debugging C++ code, and reused in many places with an absolute minimum of fuss or danger.
I present you with the following link, which illustrates a number of very useful data structures in LLVM/Clang that are used all over the place, and which either do not exist, exist but are a bitch to use correctly, or which are copy-pastad all over the place in GCC:
Posted Mar 23, 2012 6:36 UTC (Fri)
by james_ulrich (guest, #83666)
[Link]
My point is that the reason GCC is a mess is not because it is written in C. Even with C++, 2000 line functions need to be logically split, and 20 line if() statements with 5 levels deep subexpression nesting also need to be split to make it readable. These, and other, de-facto coding style idiosyncrasies need to be fixed (or at least agreed upon not to write code like that), which is in no way affected by the C/C++ decision.
GCC also has this "property", let's say, that code is never actually re-written, only new methods added in parallel to the old ones. Classic examples are the CC_FLAGS/cc0 thing and best of all reload. Everyone knew it sucked 15 years ago, yet only now are motions made in the form of LRA to replace it (which, BTW, are in now way motivated by using C++). The same can be said for the old register allocator, combine, etc. I somehow doubt that C++ alone would magically motivate anyone to start rewriting these old, convoluted but critical pieces.
Based on past observations my prediction for GCC-in-C++ is that all the old ugly code will simply stay, the style will not really change, but now it will ugly code mixed with C++ constructs.
Posted Mar 23, 2012 2:00 UTC (Fri)
by HelloWorld (guest, #56129)
[Link]
Posted Mar 23, 2012 3:31 UTC (Fri)
by wahern (subscriber, #37304)
[Link]
Posted Mar 25, 2012 0:56 UTC (Sun)
by nix (subscriber, #2304)
[Link] (2 responses)
Its biggest problem -- still pervasive in the RTL side of things -- was always global, unstated assumptions, often assumptions wired into target machine description files, RTL optimization passes, and reload. Often an RTL optimization pass would assume (or would grow to assume over years, accidentally) some property of md files that was true for all existing md files but not necessarily true, and then reload would come to depend on the form of the RTL emitted by optimization files when when that property was true. Some of these properties are much nastier than CC0 and can't be grepped for -- and fixing them requires understanding a lot of targets, and *testing* them.
This is slowly being sorted out as more machinery migrates into the tree-ssa side of things, and as older and cruftier targets are slowly decommissioned. But it's a slow, slow job, and it would be every bit as slow regardless of the implementation language. (This is one reason why reload has been such a monster to dump and replace: it's where all these unstated assumptions go to roost. Break just one of them and you might find yourself with wrong code on a couple of random targets you'd never heard of, and the poor sod who finds this is going to have the devil of a time tracking it down to your change.)
Posted Mar 25, 2012 8:49 UTC (Sun)
by james_ulrich (guest, #83666)
[Link] (1 responses)
While I had my share of struggling with reload, by far most of the annoying problems with RTL passes was that lot's of them completely ignore some MD feature or other -- it can not even be said that this is old cruft hanging around: even the web construction pass has issues, which is supposed to serve as an example! This is a review problem.
Posted Mar 26, 2012 19:32 UTC (Mon)
by nix (subscriber, #2304)
[Link]
(This is not to say that you are wrong in any way. There are other problems too, not least the 'it works on major targets' RTL, it must be complete' problem you mention...)
Continuity problems
Continuity problems
Continuity problems
Continuity problems
Continuity problems
Continuity problems
Continuity problems
Continuity problems