public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch] lto/lto.c – used $ or . in generated linkptr name
@ 2020-03-23 13:10 Tobias Burnus
  2020-03-23 13:19 ` Jakub Jelinek
  0 siblings, 1 reply; 2+ messages in thread
From: Tobias Burnus @ 2020-03-23 13:10 UTC (permalink / raw)
  To: gcc-patches, Jakub Jelinek, Richard Biener

[-- Attachment #1: Type: text/plain, Size: 379 bytes --]

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

[-- Attachment #2: lto-sep.diff --]
[-- Type: text/x-patch, Size: 843 bytes --]

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;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Patch] lto/lto.c – used $ or . in generated linkptr name
  2020-03-23 13:10 [Patch] lto/lto.c – used $ or . in generated linkptr name Tobias Burnus
@ 2020-03-23 13:19 ` Jakub Jelinek
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2020-03-23 13:19 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gcc-patches, Richard Biener

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-23 13:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-23 13:10 [Patch] lto/lto.c – used $ or . in generated linkptr name Tobias Burnus
2020-03-23 13:19 ` Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).