Patchwork [rs6000] Fix thinko in output_profile_hook

login
register
mail settings
Submitter Eric Botcazou
Date March 24, 2011, 2:52 p.m.
Message ID <201103241552.52635.ebotcazou@adacore.com>
Download mbox | patch
Permalink /patch/88210/
State New
Headers show

Comments

Eric Botcazou - March 24, 2011, 2:52 p.m.
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  <ebotcazou@adacore.com>

	* config/rs6000/rs6000.c (output_profile_hook): Fix thinko.
Eric Botcazou - May 8, 2011, 9:04 a.m.
> 2011-03-24  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * config/rs6000/rs6000.c (output_profile_hook): Fix thinko.

Applied as obvious.

Patch

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),