This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Compiler uses a lot of memory for large initialized arrays


On Thu, Dec 02, 2004 at 04:34:35PM +0000, Joseph S. Myers wrote:
> On Thu, 2 Dec 2004, Ian Lance Taylor wrote:
> 
> > This test case works fine with 2.95.3.  Looking into the patches I
> > came across this note from you from four years ago:
> >     http://gcc.gnu.org/ml/gcc-patches/2000-10/msg00937.html
> 
> And hopefully you came across the November part of the thread as well: C99 
> designated initializers allow
> 
> int i[10000000] = { 0, 1, 2, 3, 4, 5, /* ... */
> 9999998, 9999999, [0] = -1 };
> 
> which stops optimizing in the simplest way by writing out initializers to 
> the assembler output before the whole initializer has been parsed.

Here's an ugly hack: write large initializers to a temporary file
(say, when the number of elements in the initializer reaches some
threshold, like 500).

If we successfully reach the end of the initializer without anything evil
like the above case, then append the temp file to the assembly output.
Otherwise, go back and do it in memory.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]