This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Can we have a symbol_ref node of a declared symbol without having its flags set?
- From: Fariborz Jahanian <fjahanian at apple dot com>
- To: gcc mailing list <gcc at gcc dot gnu dot org>
- Date: Thu, 15 Sep 2005 16:45:11 -0700
- Subject: Can we have a symbol_ref node of a declared symbol without having its flags set?
I ran into a problem when chasing down an -mfix-and-continue (an
apple specialty :) code-gen problem.
In a test case, ivopts creates a symbol_ref via a call to
produce_memory_decl_rtl; as in:
if (TREE_STATIC (obj) || DECL_EXTERNAL (obj))
{
const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME
(obj));
x = gen_rtx_SYMBOL_REF (Pmode, name);
}
...
But it does not set the flags for this symbol. This causes code gen
problem in certain cases ; such as in apple-ppc-darwin PIC generation
code, which rely on these flags. An obvious fix come to mind is to
set the flags when symbol_ref is created. Such as in this patch. But
a more general question is should we always set the flags for
symbol_ref whenever such a node is created for a declared symbol?
--- 2376,2404 ----
static rtx
produce_memory_decl_rtl (tree obj, int *regno)
{
! rtx x, ret;
if (!obj)
abort ();
if (TREE_STATIC (obj) || DECL_EXTERNAL (obj))
{
const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME
(obj));
x = gen_rtx_SYMBOL_REF (Pmode, name);
+ ret = gen_rtx_MEM (DECL_MODE (obj), x);
+ SET_DECL_RTL (obj, ret);
+ targetm.encode_section_info (obj, DECL_RTL (obj), true);
}
else
! {
! x = gen_raw_REG (Pmode, (*regno)++);
! ret = gen_rtx_MEM (DECL_MODE (obj), x);
! }
! return ret;
}
Thanks, fariborz (fjahanian@apple.com)