summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog22
-rw-r--r--gcc/config/i386/cygming.h4
-rw-r--r--gcc/config/i386/i386-protos.h1
-rw-r--r--gcc/config/i386/winnt.c14
-rw-r--r--gcc/doc/tm.texi4
-rw-r--r--gcc/doc/tm.texi.in2
-rw-r--r--gcc/lto-streamer-out.c10
-rw-r--r--gcc/lto-symtab.c12
-rw-r--r--gcc/target.def12
-rw-r--r--gcc/targhooks.c11
-rw-r--r--gcc/targhooks.h2
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/pr43157.c19
-rw-r--r--lto-plugin/ChangeLog9
-rw-r--r--lto-plugin/config.h.in3
-rwxr-xr-xlto-plugin/configure18
-rw-r--r--lto-plugin/configure.ac12
-rw-r--r--lto-plugin/lto-plugin.c4
18 files changed, 120 insertions, 45 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f967a667cb8..588a8cfdc95 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,25 @@
+2010-12-10 Dave Korn <dave.korn.cygwin@gmail.com>
+
+ PR middle-end/46674
+ PR lto/43157
+ * target.def (mangle_assembler_name): New target asm_out hook.
+ * targhooks.c (default_mangle_assembler_name): Add default hook
+ implementation.
+ * targhooks.h (default_mangle_assembler_name): Add prototype.
+ * lto-symtab.c (lto_symtab_register_decl): Use new hook when
+ processing DECL_ASSEMBLER_NAMEs for lto symtabs.
+ (lto_symtab_get_resolution): Likewise.
+ (lto_cgraph_replace_node): Likewise.
+ (lto_symtab_prevailing_decl): Likewise.
+ * lto-streamer-out.c (write_symbol): Likewise.
+ * doc/tm.texi.in (TARGET_MANGLE_ASSEMBLER_NAME): Add @hook directive.
+ * doc/tm.texi: Regenerate.
+ * config/i386/cygming.h (TARGET_MANGLE_ASSEMBLER_NAME): Define to
+ point at i386_pe_mangle_assembler_name.
+ * config/i386/winnt.c (i386_pe_mangle_assembler_name): New function.
+ * config/i386/i386-protos.h (i386_pe_mangle_assembler_name): Add
+ prototype.
+
2010-12-10 Nathan Froyd <froydnj@codesourcery.com>
* c-typeck.c (readonly_error): Delete.
diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h
index 733c7c79a37..be97d806132 100644
--- a/gcc/config/i386/cygming.h
+++ b/gcc/config/i386/cygming.h
@@ -252,6 +252,10 @@ do { \
fputs ((NAME), (STREAM)); \
} while (0)
+/* This does much the same in memory rather than to a stream. */
+#undef TARGET_MANGLE_ASSEMBLER_NAME
+#define TARGET_MANGLE_ASSEMBLER_NAME i386_pe_mangle_assembler_name
+
/* Emit code to check the stack when allocating more than 4000
bytes in one go. */
diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
index 3936099e443..1180e8ce4da 100644
--- a/gcc/config/i386/i386-protos.h
+++ b/gcc/config/i386/i386-protos.h
@@ -226,6 +226,7 @@ extern void i386_pe_file_end (void);
extern void i386_pe_start_function (FILE *, const char *, tree);
extern void i386_pe_end_function (FILE *, const char *, tree);
extern tree i386_pe_mangle_decl_assembler_name (tree, tree);
+extern tree i386_pe_mangle_assembler_name (const char *);
extern void i386_pe_seh_init (FILE *);
extern void i386_pe_seh_end_prologue (FILE *);
diff --git a/gcc/config/i386/winnt.c b/gcc/config/i386/winnt.c
index 16110a71508..098efa3d18f 100644
--- a/gcc/config/i386/winnt.c
+++ b/gcc/config/i386/winnt.c
@@ -244,6 +244,20 @@ i386_pe_mangle_decl_assembler_name (tree decl, tree id)
return (new_id ? new_id : id);
}
+/* This hook behaves the same as varasm.c/assemble_name(), but
+ generates the name into memory rather than outputting it to
+ a file stream. */
+
+tree
+i386_pe_mangle_assembler_name (const char *name ATTRIBUTE_UNUSED)
+{
+ const char *skipped = name + (*name == '*' ? 1 : 0);
+ const char *stripped = targetm.strip_name_encoding (skipped);
+ if (*name != '*' && *user_label_prefix && *stripped != FASTCALL_PREFIX)
+ stripped = ACONCAT ((user_label_prefix, stripped, NULL));
+ return get_identifier (stripped);
+}
+
void
i386_pe_encode_section_info (tree decl, rtx rtl, int first)
{
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 7ebe039e4ff..32ffb8c1489 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -8041,6 +8041,10 @@ is customary on your operating system, as it is in most Berkeley Unix
systems. This macro is used in @code{assemble_name}.
@end defmac
+@deftypefn {Target Hook} tree TARGET_MANGLE_ASSEMBLER_NAME (const char *@var{name})
+Given a symbol @var{name}, perform same mangling as @code{varasm.c}'s @code{assemble_name}, but in memory rather than to a file stream, returning result as an @code{IDENTIFIER_NODE}. Required for correct LTO symtabs. The default implementation calls the @code{TARGET_STRIP_NAME_ENCODING} hook and then prepends the @code{USER_LABEL_PREFIX}, if any.
+@end deftypefn
+
@defmac ASM_OUTPUT_SYMBOL_REF (@var{stream}, @var{sym})
A C statement (sans semicolon) to output a reference to
@code{SYMBOL_REF} @var{sym}. If not defined, @code{assemble_name}
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index c85dfa28fd4..b4ab96654e5 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -8013,6 +8013,8 @@ is customary on your operating system, as it is in most Berkeley Unix
systems. This macro is used in @code{assemble_name}.
@end defmac
+@hook TARGET_MANGLE_ASSEMBLER_NAME
+
@defmac ASM_OUTPUT_SYMBOL_REF (@var{stream}, @var{sym})
A C statement (sans semicolon) to output a reference to
@code{SYMBOL_REF} @var{sym}. If not defined, @code{assemble_name}
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index a3f7b1cc019..2bf83bebde4 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -2368,16 +2368,14 @@ write_symbol (struct lto_streamer_cache_d *cache,
name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (t));
+ /* This behaves like assemble_name_raw in varasm.c, performing the
+ same name manipulations that ASM_OUTPUT_LABELREF does. */
+ name = IDENTIFIER_POINTER ((*targetm.asm_out.mangle_assembler_name) (name));
+
if (pointer_set_contains (seen, name))
return;
pointer_set_insert (seen, name);
- /* FIXME lto: this is from assemble_name_raw in varasm.c. For some
- architectures we might have to do the same name manipulations that
- ASM_OUTPUT_LABELREF does. */
- if (name[0] == '*')
- name = &name[1];
-
lto_streamer_cache_lookup (cache, t, &slot_num);
gcc_assert (slot_num >= 0);
diff --git a/gcc/lto-symtab.c b/gcc/lto-symtab.c
index dbdbcb2996e..c86bbcc8a5a 100644
--- a/gcc/lto-symtab.c
+++ b/gcc/lto-symtab.c
@@ -155,7 +155,8 @@ lto_symtab_register_decl (tree decl,
gcc_assert (!DECL_ABSTRACT (decl));
new_entry = ggc_alloc_cleared_lto_symtab_entry_def ();
- new_entry->id = DECL_ASSEMBLER_NAME (decl);
+ new_entry->id = (*targetm.asm_out.mangle_assembler_name)
+ (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
new_entry->decl = decl;
new_entry->resolution = resolution;
new_entry->file_data = file_data;
@@ -190,7 +191,8 @@ lto_symtab_get_resolution (tree decl)
gcc_assert (DECL_ASSEMBLER_NAME_SET_P (decl));
- e = lto_symtab_get (DECL_ASSEMBLER_NAME (decl));
+ e = lto_symtab_get ((*targetm.asm_out.mangle_assembler_name)
+ (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
while (e && e->decl != decl)
e = e->next;
if (!e)
@@ -218,7 +220,8 @@ lto_cgraph_replace_node (struct cgraph_node *node,
cgraph_node_name (node), node->uid,
cgraph_node_name (prevailing_node),
prevailing_node->uid,
- IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (node->decl)));
+ IDENTIFIER_POINTER ((*targetm.asm_out.mangle_assembler_name)
+ (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (node->decl)))));
}
if (prevailing_node->same_body_alias)
@@ -836,7 +839,8 @@ lto_symtab_prevailing_decl (tree decl)
gcc_assert (DECL_ASSEMBLER_NAME_SET_P (decl));
/* Walk through the list of candidates and return the one we merged to. */
- ret = lto_symtab_get (DECL_ASSEMBLER_NAME (decl));
+ ret = lto_symtab_get ((*targetm.asm_out.mangle_assembler_name)
+ (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
if (!ret)
return NULL_TREE;
diff --git a/gcc/target.def b/gcc/target.def
index 8162d763f12..653981f71ad 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -524,6 +524,18 @@ DEFHOOK_UNDOC
bool ,(unsigned char code),
default_print_operand_punct_valid_p)
+/* Given a symbol name, perform same mangling as assemble_name and
+ ASM_OUTPUT_LABELREF, returning result as an IDENTIFIER_NODE. */
+DEFHOOK
+(mangle_assembler_name,
+ "Given a symbol @var{name}, perform same mangling as @code{varasm.c}'s\
+ @code{assemble_name}, but in memory rather than to a file stream, returning\
+ result as an @code{IDENTIFIER_NODE}. Required for correct LTO symtabs. The\
+ default implementation calls the @code{TARGET_STRIP_NAME_ENCODING} hook and\
+ then prepends the @code{USER_LABEL_PREFIX}, if any.",
+ tree, (const char *name),
+ default_mangle_assembler_name)
+
HOOK_VECTOR_END (asm_out)
/* Functions relating to instruction scheduling. All of these
diff --git a/gcc/targhooks.c b/gcc/targhooks.c
index 0eee5288b6c..30a58911d2e 100644
--- a/gcc/targhooks.c
+++ b/gcc/targhooks.c
@@ -358,6 +358,17 @@ default_print_operand_punct_valid_p (unsigned char code ATTRIBUTE_UNUSED)
#endif
}
+/* The default implementation of TARGET_MANGLE_ASSEMBLER_NAME. */
+tree
+default_mangle_assembler_name (const char *name ATTRIBUTE_UNUSED)
+{
+ const char *skipped = name + (*name == '*' ? 1 : 0);
+ const char *stripped = targetm.strip_name_encoding (skipped);
+ if (*name != '*' && user_label_prefix[0])
+ stripped = ACONCAT ((user_label_prefix, stripped, NULL));
+ return get_identifier (stripped);
+}
+
/* The default implementation of TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA. */
bool
diff --git a/gcc/targhooks.h b/gcc/targhooks.h
index db6f7146b00..d34ad9f52a1 100644
--- a/gcc/targhooks.h
+++ b/gcc/targhooks.h
@@ -65,6 +65,8 @@ extern bool hook_callee_copies_named
extern void default_print_operand (FILE *, rtx, int);
extern void default_print_operand_address (FILE *, rtx);
extern bool default_print_operand_punct_valid_p (unsigned char);
+extern tree default_mangle_assembler_name (const char *);
+
extern bool default_asm_output_addr_const_extra (FILE *, rtx);
extern bool default_scalar_mode_supported_p (enum machine_mode);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8322e96ca59..9705844d5ef 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2010-12-10 Dave Korn <dave.korn.cygwin@gmail.com>
+
+ PR middle-end/46674
+ PR lto/43157
+ * gcc.dg/pr43157.c: New file.
+
2010-12-10 Nathan Froyd <froydnj@codesourcery.com>
* gcc.dg/dfp/struct-union.c: Adjust.
diff --git a/gcc/testsuite/gcc.dg/pr43157.c b/gcc/testsuite/gcc.dg/pr43157.c
new file mode 100644
index 00000000000..aef357f69d7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr43157.c
@@ -0,0 +1,19 @@
+/* { dg-do link } */
+/* { dg-require-effective-target lto } */
+/* { dg-options "-O1 -flto -fuse-linker-plugin" } */
+
+#define LABEL3(pfx, x) # pfx x
+#define LABEL2(pfx, x) LABEL3(pfx, x)
+#define LABEL(x) LABEL2(__USER_LABEL_PREFIX__, x)
+
+unsigned int factorial_ (unsigned int) __asm__ (LABEL ("factorial"));
+
+unsigned int factorial (unsigned int i)
+{
+ return i > 1 ? i * factorial_ (i - 1) : 1;
+}
+
+int main (void)
+{
+ return factorial (5);
+}
diff --git a/lto-plugin/ChangeLog b/lto-plugin/ChangeLog
index 305db4e9877..2dda3172852 100644
--- a/lto-plugin/ChangeLog
+++ b/lto-plugin/ChangeLog
@@ -1,3 +1,12 @@
+2010-12-10 Dave Korn <dave.korn.cygwin@gmail.com>
+
+ PR middle-end/46674
+ PR lto/43157
+ * configure.ac (SYM_STYLE): Don't AC_DEFINE.
+ * lto-plugin.c (sym_style): Don't use it; default to ss_none.
+ * configure: Regenerate.
+ * config.h.in: Likewise.
+
2010-12-06 Dave Korn <dave.korn.cygwin@gmail.com>
PR target/40125
diff --git a/lto-plugin/config.h.in b/lto-plugin/config.h.in
index a591ccc7b36..ad003b2925e 100644
--- a/lto-plugin/config.h.in
+++ b/lto-plugin/config.h.in
@@ -61,9 +61,6 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
-/* Default symbol style */
-#undef SYM_STYLE
-
/* Version number of package */
#undef VERSION
diff --git a/lto-plugin/configure b/lto-plugin/configure
index 12e58e5d867..495d9e9ed60 100755
--- a/lto-plugin/configure
+++ b/lto-plugin/configure
@@ -10872,24 +10872,6 @@ esac
-# Trying to get this information from gcc's config is tricky.
-case $target in
- x86_64*-mingw*)
-
-$as_echo "#define SYM_STYLE ss_none" >>confdefs.h
-
- ;;
- *-cygwin* | i?86*-mingw* )
-
-$as_echo "#define SYM_STYLE ss_win32" >>confdefs.h
-
- ;;
- *)
-
-$as_echo "#define SYM_STYLE ss_none" >>confdefs.h
-
- ;;
-esac
ac_fn_c_find_intX_t "$LINENO" "64" "ac_cv_c_int64_t"
case $ac_cv_c_int64_t in #(
no|yes) ;; #(
diff --git a/lto-plugin/configure.ac b/lto-plugin/configure.ac
index 67147db6817..1aba69713f7 100644
--- a/lto-plugin/configure.ac
+++ b/lto-plugin/configure.ac
@@ -9,18 +9,6 @@ AC_SYS_LARGEFILE
AM_PROG_LIBTOOL
ACX_LT_HOST_FLAGS
AC_SUBST(target_noncanonical)
-# Trying to get this information from gcc's config is tricky.
-case $target in
- x86_64*-mingw*)
- AC_DEFINE([SYM_STYLE], [ss_none], [Default symbol style])
- ;;
- *-cygwin* | i?86*-mingw* )
- AC_DEFINE([SYM_STYLE], [ss_win32], [Default symbol style])
- ;;
- *)
- AC_DEFINE([SYM_STYLE], [ss_none], [Default symbol style])
- ;;
-esac
AC_TYPE_INT64_T
AC_TYPE_UINT64_T
AC_HEADER_SYS_WAIT
diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c
index 5ca4c9a27a3..ab18f4c6d9c 100644
--- a/lto-plugin/lto-plugin.c
+++ b/lto-plugin/lto-plugin.c
@@ -152,10 +152,10 @@ static char debug;
static char nop;
static char *resolution_file = NULL;
-/* Set by default from configure.ac, but can be overridden at runtime
+/* Not used by default, but can be overridden at runtime
by using -plugin-opt=-sym-style={none,win32,underscore|uscore}
(in fact, only first letter of style arg is checked.) */
-static enum symbol_style sym_style = SYM_STYLE;
+static enum symbol_style sym_style = ss_none;
static void
check_1 (int gate, enum ld_plugin_level level, const char *text)