On Tue, 10 Jun 2008, Joern Rennecke wrote:
> > From: "Ian Lance Taylor" <[EMAIL PROTECTED]>
> > >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;
}