From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11806 invoked by alias); 2 Dec 2004 18:18:11 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 11762 invoked from network); 2 Dec 2004 18:18:05 -0000 Received: from unknown (HELO vaxjo.synopsys.com) (198.182.60.75) by sourceware.org with SMTP; 2 Dec 2004 18:18:05 -0000 Received: from mother.synopsys.com (mother.synopsys.com [146.225.100.171]) by vaxjo.synopsys.com (Postfix) with ESMTP id B811BDA5B; Thu, 2 Dec 2004 10:18:04 -0800 (PST) Received: from piper.synopsys.com (localhost [127.0.0.1]) by mother.synopsys.com (8.9.1/8.9.1) with ESMTP id KAA13110; Thu, 2 Dec 2004 10:18:03 -0800 (PST) Received: (from jbuck@localhost) by piper.synopsys.com (8.11.6/8.11.6) id iB2II3T19204; Thu, 2 Dec 2004 10:18:03 -0800 X-Authentication-Warning: piper.synopsys.com: jbuck set sender to Joe.Buck@synopsys.com using -f Date: Thu, 02 Dec 2004 18:18:00 -0000 From: Joe Buck To: "Joseph S. Myers" Cc: Ian Lance Taylor , mark@codesourcery.com, gcc@gcc.gnu.org Subject: Re: Compiler uses a lot of memory for large initialized arrays Message-ID: <20041202101803.A18628@synopsys.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: ; from joseph@codesourcery.com on Thu, Dec 02, 2004 at 04:34:35PM +0000 X-SW-Source: 2004-12/txt/msg00142.txt.bz2 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.