This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Is there really only one symbol_ref object referring to eachsymbolic label?
> Date: Sat, 28 Jun 2003 12:09:26 -0400 (EDT)
> Cc: gcc@gcc.gnu.org
> From: Kazu Hirata <kazu@cs.umass.edu>
> Hi Geoff,
>
> > > GCC Internals Manual states that
> > >
> > > For any symbolic label, there is only one symbol_ref object
> > > referring to it.
> > >
> > > Does this mean x == y iff XSTR (x, 0) == XSTR (y, 0), assuming both x
> > > and y are SYMBOL_REF? If so, looking at gen_rtx_SYMBOL_REF, I think
> > > we can get two different rtx objects just by saying
> > >
> > > x = gen_rtx_SYMBOL_REF (Pmode, "hello");
> > > y = gen_rtx_SYMBOL_REF (Pmode, strdup ("hello"));
> > >
> > > Or are we not supposed to do this?
> >
> > Strings in SYMBOL_REFs are supposed to live in the identifier hash
> > table, and so should be unique...
>
> I see. Then I guess it could potentially be dangerous to have
> multiple places creating the same SYMBOL_REFs like
>
> sh/sh.md:8059: operands[2] = gen_rtx_SYMBOL_REF (SImode, \"__fpscr_values\");
> sh/sh.md:8073: operands[2] = gen_rtx_SYMBOL_REF (SImode, \"__fpscr_values\");
>
> and
>
> sparc/sparc.md:1937: operands[2] = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_");
> sparc/sparc.md:2178: operands[2] = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_");
> x
>
> because rtx_equal_p and a *lot* of its variants use
>
> XSTR (x, 0) == XSTR (y, 0)
>
> to compare two SYMBOL_REFs. If the host compiler assigns two
> identical string constants two different addresses, the comparison may
> fail.
Yup. They should look like
gen_rtx_SYMBOL_REF (xxx, ggc_strdup ("yyy"))
You don't want to make the ggc_strdup be part of gen_rtx_* because 99%
of the time it's not necessary and the extra hash-table lookup is slow...
Perhaps there should be a check in gen_rtx_fmt_* when debugging is on
so that when it does
XSTR (rt, 0) = arg0;
it also does:
#if ENABLE_CHECKING_XXX
if (ggc_strdup (arg0) != arg0)
abort ();
#endif
--
- Geoffrey Keating <geoffk@geoffk.org>