Commit 6788f5ca by Geoffrey Keating Committed by Geoffrey Keating

rs6000.c (rs6000_emit_prologue): Don't clone the result of machopic_function_base_name.

	* config/rs6000/rs6000.c (rs6000_emit_prologue): Don't clone
	the result of machopic_function_base_name.
	* config/darwin.c (machopic_function_base_name): Use a gc-allocated
	string rather than a static array.

From-SVN: r64569
parent 178274da
...@@ -18,6 +18,11 @@ ...@@ -18,6 +18,11 @@
2003-03-18 Geoffrey Keating <geoffk@apple.com> 2003-03-18 Geoffrey Keating <geoffk@apple.com>
* config/rs6000/rs6000.c (rs6000_emit_prologue): Don't clone
the result of machopic_function_base_name.
* config/darwin.c (machopic_function_base_name): Use a gc-allocated
string rather than a static array.
* Makefile.in (emit-rtl.o): Add gt-emit-rtl.h to dependencies. * Makefile.in (emit-rtl.o): Add gt-emit-rtl.h to dependencies.
* gengtype.c: Include rtl.h. * gengtype.c: Include rtl.h.
......
...@@ -219,24 +219,26 @@ machopic_define_name (name) ...@@ -219,24 +219,26 @@ machopic_define_name (name)
} }
/* This is a static to make inline functions work. The rtx /* This is a static to make inline functions work. The rtx
representing the PIC base symbol always points to here. */ representing the PIC base symbol always points to here.
static char function_base[32]; FIXME: The rest of the compiler doesn't expect strings to change. */
static GTY(()) char * function_base;
static GTY(()) const char * function_base_func_name;
static GTY(()) int current_pic_label_num; static GTY(()) int current_pic_label_num;
const char * const char *
machopic_function_base_name () machopic_function_base_name ()
{ {
static const char *name = NULL; const char *current_name;
static const char *current_name;
/* if dynamic-no-pic is on, we should not get here */ /* if dynamic-no-pic is on, we should not get here */
if (MACHO_DYNAMIC_NO_PIC_P) if (MACHO_DYNAMIC_NO_PIC_P)
abort (); abort ();
current_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl)); current_name =
IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl));
if (name != current_name) if (function_base_func_name != current_name)
{ {
current_function_uses_pic_offset_table = 1; current_function_uses_pic_offset_table = 1;
...@@ -246,13 +248,21 @@ machopic_function_base_name () ...@@ -246,13 +248,21 @@ machopic_function_base_name ()
by the incredibly scientific test below. This is because code in by the incredibly scientific test below. This is because code in
rs6000.c makes the same ugly test when loading the PIC reg. */ rs6000.c makes the same ugly test when loading the PIC reg. */
/* It's hard to describe just how ugly this is. The reason for
the '%011d' is that after a PCH load, we can't change the
size of the string, because PCH will have uniqued it and
allocated it in the string pool. */
if (function_base == NULL)
function_base =
(char *) ggc_alloc_string ("", sizeof ("*\"L12345678901$pb\""));
++current_pic_label_num; ++current_pic_label_num;
if (*current_name == '+' || *current_name == '-') if (*current_name == '+' || *current_name == '-')
sprintf (function_base, "*\"L-%d$pb\"", current_pic_label_num); sprintf (function_base, "*\"L-%010d$pb\"", current_pic_label_num);
else else
sprintf (function_base, "*L%d$pb", current_pic_label_num); sprintf (function_base, "*\"L%011d$pb\"", current_pic_label_num);
name = current_name; function_base_func_name = current_name;
} }
return function_base; return function_base;
......
...@@ -10799,7 +10799,7 @@ rs6000_emit_prologue () ...@@ -10799,7 +10799,7 @@ rs6000_emit_prologue ()
{ {
rtx dest = gen_rtx_REG (Pmode, LINK_REGISTER_REGNUM); rtx dest = gen_rtx_REG (Pmode, LINK_REGISTER_REGNUM);
const char *picbase = machopic_function_base_name (); const char *picbase = machopic_function_base_name ();
rtx src = gen_rtx_SYMBOL_REF (Pmode, ggc_alloc_string (picbase, -1)); rtx src = gen_rtx_SYMBOL_REF (Pmode, picbase);
rs6000_maybe_dead (emit_insn (gen_load_macho_picbase (dest, src))); rs6000_maybe_dead (emit_insn (gen_load_macho_picbase (dest, src)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment