https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66682

Mikhail Maltsev <miyuki at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.9.0

--- Comment #8 from Mikhail Maltsev <miyuki at gcc dot gnu.org> ---
(In reply to Brendan G Bohannon from comment #7)
> The code in question creates about 7k internal functions, which could be a
> factor?
Well, yes probably the number of functions does matter here. But again, this is
a bug in GCC, which has been fixed in later versions (4.9.x and later).
I can even point out the relevant commit. I prepared a slightly reduced
testcase (all 6-argument thunks, ~2000 functions). Bisection shows that r208113
compiles the testcase in 7.5s (at -O0), while the previous revision requires 71
second (and over 6 minutes for full testcase).
BTW, r208113 is a fix for PR60291 - a similar issue with C code which is
generated by glasgow haskell compiler.

> The VM it is from, in general, creates large numbers of one-off functions
> via macros. Most of this is because the interpreter structure is built
> around structs and calls through function-pointers (with the bytecode
> decoded into "Traces", AKA: "Extended Basic Blocks", which are executed via
> unrolled loops of calls through function-pointers, in turn driven by a
> top-level trampoline loop). Functions for basic operations are expanded out
> in terms of combinations of parameter and data types (in turn, the functions
> are fairly specialized).
Well, this has some similarities with GCC. For example, there are ~5000
functions (on x86) which construct RTL instructions (one of intermediate
representations in GCC), that is ~150k lines of code. Converting expressions
into actual instructions is typically done using a kind of pattern matching.
The "matcher" (recognizer) is implemented as a set of ~1000 rather complex
generated functions, their total size is ~120k lines (again, for x86). What I
mean by this is that normally GCC should have no problems with large generated
code.

Reply via email to