From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2780 invoked by alias); 10 Jun 2008 17:44:35 -0000 Received: (qmail 2770 invoked by uid 22791); 10 Jun 2008 17:44:34 -0000 X-Spam-Check-By: sourceware.org Received: from caip.rutgers.edu (HELO caip.rutgers.edu) (128.6.236.16) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 10 Jun 2008 17:44:15 +0000 Received: from caipclassic.rutgers.edu (caipclassic.rutgers.edu [128.6.237.54]) by caip.rutgers.edu (8.13.8/8.13.8) with ESMTP id m5AHi8Jk022981 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 10 Jun 2008 13:44:08 -0400 Date: Tue, 10 Jun 2008 17:44:00 -0000 From: "Kaveh R. GHAZI" To: Joern Rennecke cc: Ian Lance Taylor , gcc@gcc.gnu.org Subject: Re: constified note_stores In-Reply-To: <20080610133836.GL32358@elsdt-razorfish.arc.com> Message-ID: References: <20080609224328.GK32358@elsdt-razorfish.arc.com> <13D82723C9864E9C93CA351786EAE74C@glap> <20080610133836.GL32358@elsdt-razorfish.arc.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2008-06/txt/msg00251.txt.bz2 On Tue, 10 Jun 2008, Joern Rennecke wrote: > > From: "Ian Lance Taylor" > > >Use CONST_CAST_RTX where necessary. > > On Mon, Jun 09, 2008 at 04:45:14PM -0700, Kaveh R. Ghazi wrote: > > Or pass in a struct pointer to the "data" parameter containing both your > > hash table and the rtx to be modified. Pull out either member in the > > walker function as necessary. > > That would require to delare this ad-hoc struct, put all the code in to > use it, and use an asm to join the proper pointer value of the pointer > to const with the un-constified pointer to the rtx root. I don't understand the point about the asm. And IMHO you overstate the effort required to "put all the code in to use [the ad-hoc struct]". One of the existing uses of CONST_CAST_RTX in alias.c also goes through note_stores. As an example, I wrote a quick (untested) patch to instead use a struct with a const_rtx member. It doesn't use an asm and seems to be completely portable ISO C90. I get no warnings when re-compiling alias.o. It's true, each function is one line longer and I had to declare the struct. But it is not an onerous amount of code. I think you can do something similar with a two-member struct containing your hash table. --Kaveh diff -rup orig/egcc-SVN20080610/gcc/alias.c egcc-SVN20080610/gcc/alias.c --- orig/egcc-SVN20080610/gcc/alias.c 2008-05-09 02:02:27.000000000 +0200 +++ egcc-SVN20080610/gcc/alias.c 2008-06-10 19:20:56.000000000 +0200 @@ -2361,15 +2361,24 @@ init_alias_target (void) #endif } +/* This is a helper structure used to pass constant data through the + functions below. */ +typedef struct mem_mod_data +{ + const_rtx mem; +} mem_mod_data; + /* Set MEMORY_MODIFIED when X modifies DATA (that is assumed to be memory reference. */ static bool memory_modified; static void memory_modified_1 (rtx x, const_rtx pat ATTRIBUTE_UNUSED, void *data) { + mem_mod_data *r = data; + if (MEM_P (x)) { - if (anti_dependence (x, (const_rtx)data) || output_dependence (x, (const_rtx)data)) + if (anti_dependence (x, r->mem) || output_dependence (x, r->mem)) memory_modified = true; } } @@ -2380,10 +2389,12 @@ memory_modified_1 (rtx x, const_rtx pat bool memory_modified_in_insn_p (const_rtx mem, const_rtx insn) { + mem_mod_data r = { mem }; + if (!INSN_P (insn)) return false; memory_modified = false; - note_stores (PATTERN (insn), memory_modified_1, CONST_CAST_RTX(mem)); + note_stores (PATTERN (insn), memory_modified_1, &r); return memory_modified; }