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?
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.
Kazu Hirata