diff mbox series

lto/lto.c – used $ or . in generated linkptr name

Message ID 4156ecb6-4f7c-a7a7-12a1-d41a42b41975@codesourcery.com
State New
Headers show
Series lto/lto.c – used $ or . in generated linkptr name | expand

Commit Message

Tobias Burnus March 23, 2020, 1:10 p.m. UTC
As discussed in IRC, it makes sense to use '$' or '.' as
separator instead of '_' – and, if it is not available,
use a '__' prefix besides the '_' suffix separator.

OK?

Tobias

-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

Comments

Jeff Law via Gcc-patches March 23, 2020, 1:19 p.m. UTC | #1
On Mon, Mar 23, 2020 at 02:10:08PM +0100, Tobias Burnus wrote:
> As discussed in IRC, it makes sense to use '$' or '.' as
> separator instead of '_' – and, if it is not available,
> use a '__' prefix besides the '_' suffix separator.
> 
> OK?

Ok (the function does what we want, although for vars is a little bit
misnamed).

> lto/lto.c – used $ or . in generated linkptr name
> 
> 	* lto.c (offload_handle_link_vars): Reduce chance of
> 	naming clashes of generated linkptr variable.
> 
> diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
> index 467b922eedf..cd34d6c9e7a 100644
> --- a/gcc/lto/lto.c
> +++ b/gcc/lto/lto.c
> @@ -561,11 +561,9 @@ offload_handle_link_vars (void)
>  			  DECL_ATTRIBUTES (var->decl)))
>        {
>  	tree type = build_pointer_type (TREE_TYPE (var->decl));
> -	tree var_name = DECL_ASSEMBLER_NAME (var->decl);
> -	char *new_name
> -	  = ACONCAT ((IDENTIFIER_POINTER (var_name), "_linkptr", NULL));
>  	tree link_ptr_var = build_decl (UNKNOWN_LOCATION, VAR_DECL,
> -					get_identifier (new_name), type);
> +					clone_function_name (var->decl,
> +							     "linkptr"), type);
>  	TREE_USED (link_ptr_var) = 1;
>  	TREE_STATIC (link_ptr_var) = 1;
>  	DECL_ARTIFICIAL (link_ptr_var) = 1;


	Jakub
diff mbox series

Patch

lto/lto.c – used $ or . in generated linkptr name

	* lto.c (offload_handle_link_vars): Reduce chance of
	naming clashes of generated linkptr variable.

diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index 467b922eedf..cd34d6c9e7a 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -561,11 +561,9 @@  offload_handle_link_vars (void)
 			  DECL_ATTRIBUTES (var->decl)))
       {
 	tree type = build_pointer_type (TREE_TYPE (var->decl));
-	tree var_name = DECL_ASSEMBLER_NAME (var->decl);
-	char *new_name
-	  = ACONCAT ((IDENTIFIER_POINTER (var_name), "_linkptr", NULL));
 	tree link_ptr_var = build_decl (UNKNOWN_LOCATION, VAR_DECL,
-					get_identifier (new_name), type);
+					clone_function_name (var->decl,
+							     "linkptr"), type);
 	TREE_USED (link_ptr_var) = 1;
 	TREE_STATIC (link_ptr_var) = 1;
 	DECL_ARTIFICIAL (link_ptr_var) = 1;