From: "Kaveh R. GHAZI" <ghazi@caip.rutgers.edu>
To: Joern Rennecke <joernr@arc.com>
Cc: Ian Lance Taylor <iant@google.com>, gcc@gcc.gnu.org
Subject: Re: constified note_stores
Date: Tue, 10 Jun 2008 17:44:00 -0000 [thread overview]
Message-ID: <Pine.GSO.4.58.0806101329001.6649@caipclassic.rutgers.edu> (raw)
In-Reply-To: <20080610133836.GL32358@elsdt-razorfish.arc.com>
On Tue, 10 Jun 2008, Joern Rennecke wrote:
> > From: "Ian Lance Taylor" <iant@google.com>
> > >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;
}
next prev parent reply other threads:[~2008-06-10 17:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-09 22:43 Joern Rennecke
2008-06-09 23:28 ` Ian Lance Taylor
2008-06-09 23:45 ` Kaveh R. Ghazi
2008-06-10 13:39 ` Joern Rennecke
2008-06-10 14:47 ` Ian Lance Taylor
2008-06-10 17:44 ` Kaveh R. GHAZI [this message]
2008-06-10 18:22 ` Joern Rennecke
2008-06-10 18:28 ` Steven Bosscher
2008-06-10 18:58 ` Joern Rennecke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.GSO.4.58.0806101329001.6649@caipclassic.rutgers.edu \
--to=ghazi@caip.rutgers.edu \
--cc=gcc@gcc.gnu.org \
--cc=iant@google.com \
--cc=joernr@arc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).