Re: [rs6000] Fix thinko in output_profile_hook

2011-05-08 Thread Eric Botcazou
> 2011-03-24  Eric Botcazou  
>
> * config/rs6000/rs6000.c (output_profile_hook): Fix thinko.

Applied as obvious.

-- 
Eric Botcazou


[rs6000] Fix thinko in output_profile_hook

2011-03-24 Thread Eric Botcazou
Hi,

the problematic line is:

label_name = (*targetm.strip_name_encoding) (ggc_strdup (buf));

On AIX, rs6000_xcoff_strip_name_encoding can return NAME + 1:

static const char *
rs6000_xcoff_strip_name_encoding (const char *name)
{
  size_t len;
  if (*name == '*')
name++;
  len = strlen (name);
  if (name[len - 1] == ']')
return ggc_alloc_string (name, len - 4);
  else
return name;
}

which means that you can have (ADDR + 1) in some GC tree and gt_ggc_m_S choke:

  if (offset)
{
  /* Here we've seen a char* which does not point to the beginning
 of an allocated object.  We assume it points to the middle of
 a STRING_CST.  */
  gcc_assert (offset == offsetof (struct tree_string, str));
  p = ((const char *) p) - offset;
  gt_ggc_mx_lang_tree_node (CONST_CAST (void *, p));
  return;
}

Tested on AIX, OK for the mainline?


2011-03-24  Eric Botcazou  

* config/rs6000/rs6000.c (output_profile_hook): Fix thinko.


-- 
Eric Botcazou
Index: config/rs6000/rs6000.c
===
--- config/rs6000/rs6000.c	(revision 171345)
+++ config/rs6000/rs6000.c	(working copy)
@@ -23002,7 +23002,7 @@ output_profile_hook (int labelno ATTRIBU
 	  rtx fun;
 
 	  ASM_GENERATE_INTERNAL_LABEL (buf, "LP", labelno);
-	  label_name = (*targetm.strip_name_encoding) (ggc_strdup (buf));
+	  label_name = ggc_strdup ((*targetm.strip_name_encoding) (buf));
 	  fun = gen_rtx_SYMBOL_REF (Pmode, label_name);
 
 	  emit_library_call (init_one_libfunc (RS6000_MCOUNT),