Re: GCC does not cope with my code

J.Scheerder@cwi.nl (Jeroen Scheerder)
28 May 2000 21:06:48 -0400

          From comp.compilers

Related articles
GCC does not cope with my code braung@ert.rwth-aachen.de (Gunnar Braun) (2000-05-24)
Re: GCC does not cope with my code mq@maq.org (2000-05-28)
Re: GCC does not cope with my code webid@asi.fr (Armel) (2000-05-28)
Re: GCC does not cope with my code chrisd@reservoir.com (Chris Dodd) (2000-05-28)
Re: GCC does not cope with my code rus@tamu.edu (Silvius Rus) (2000-05-28)
Re: GCC does not cope with my code bonzini@gnu.org (2000-05-28)
Re: GCC does not cope with my code gnb@itga.com.au (Gregory Bond) (2000-05-28)
Re: GCC does not cope with my code J.Scheerder@cwi.nl (2000-05-28)
Re: GCC does not cope with my code Wilco.Dijkstra@arm.com (Wilco Dijkstra) (2000-05-28)
Re: GCC does not cope with my code braung@ert.rwth-aachen.de (Gunnar Braun) (2000-05-31)
Re: GCC does not cope with my code bosch@nile.gnat.com (Geert Bosch) (2000-06-04)
| List of all articles for this month |

From: J.Scheerder@cwi.nl (Jeroen Scheerder)
Newsgroups: comp.compilers
Date: 28 May 2000 21:06:48 -0400
Organization: NAKA
References: 00-05-091
Keywords: GCC, practice

Gunnar Braun:


> I'm currently developing tools that generate C++ code. The generated
> code contains a bunch of macros which are expanded by the preprocessor.
> No problem up to here. Now I'd like to compile the resulting file with
> g++, but it takes ages until I get the object file. It gets worse, if I
> try to optimize the code generation via -O (of course it gets). The
> problem is that the (source) file (after the macro expansion) isn't
> really large, it's below 700 kB. If the file gets above 700 kB, the
> compiler crashes with the famous signal 11 internal compiler error.


[...]


> What is wrong with the generated source file that the compiler doesn't
> cope with it?


This is (in my humble experience) rather typical for generated code
in which you often find functions with a huge number of `case's in
a switch statement. Optimizers tend to run into difficulties as the
size of functions, and the size of the state space induced by complex
conditional constructs, increases.


> What changes can I apply to the _code_ to reduce compile time/make it
> possible to compile the file?


Break up large functions; wrap switch statement with huge amounts of
cases in enclosing functions that use conditional constructs to dispatch
to several smaller switch statements, for example, if you want to make
the optizer's life easier.


The internal errors, by the way, may just be resource exhaustion. Your
shell is likely to have a `limit' command built in; use it to find out
if there's perhaps an upper limit to the memory that running tools can
claim. Limiting user tools to 128MB is not unusual; but I've seen gcc's
optimization phase require considerably more on generated code not unlike
your example.




-- J$


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.