public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] LTO plugin: modernize a bit.
@ 2022-05-03 14:04 Martin Liška
  2022-05-03 15:12 ` Jeff Law
  0 siblings, 1 reply; 6+ messages in thread
From: Martin Liška @ 2022-05-03 14:04 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jan Hubicka

This is a follow up patch of something I sent last stage1.
I'm not planning moving to C++, but I would like to see this patch
go in.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

include/ChangeLog:

	* plugin-api.h (enum ld_plugin_tag): Do not set implicit enum
	values.

lto-plugin/ChangeLog:

	* lto-plugin.c (struct plugin_objfile): Use bool for offset
	field.
	(exec_lto_wrapper): Assign true/false to bool variables.
	(process_offload_section): Likewise.
	(claim_file_handler): Likewise.
	(onload): Likewise.
---
 include/plugin-api.h    | 68 ++++++++++++++++++++---------------------
 lto-plugin/lto-plugin.c | 19 ++++++------
 2 files changed, 44 insertions(+), 43 deletions(-)

diff --git a/include/plugin-api.h b/include/plugin-api.h
index 4e12c0320d6..8aebe2ff267 100644
--- a/include/plugin-api.h
+++ b/include/plugin-api.h
@@ -487,40 +487,40 @@ enum ld_plugin_level
 
 enum ld_plugin_tag
 {
-  LDPT_NULL = 0,
-  LDPT_API_VERSION = 1,
-  LDPT_GOLD_VERSION = 2,
-  LDPT_LINKER_OUTPUT = 3,
-  LDPT_OPTION = 4,
-  LDPT_REGISTER_CLAIM_FILE_HOOK = 5,
-  LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK = 6,
-  LDPT_REGISTER_CLEANUP_HOOK = 7,
-  LDPT_ADD_SYMBOLS = 8,
-  LDPT_GET_SYMBOLS = 9,
-  LDPT_ADD_INPUT_FILE = 10,
-  LDPT_MESSAGE = 11,
-  LDPT_GET_INPUT_FILE = 12,
-  LDPT_RELEASE_INPUT_FILE = 13,
-  LDPT_ADD_INPUT_LIBRARY = 14,
-  LDPT_OUTPUT_NAME = 15,
-  LDPT_SET_EXTRA_LIBRARY_PATH = 16,
-  LDPT_GNU_LD_VERSION = 17,
-  LDPT_GET_VIEW = 18,
-  LDPT_GET_INPUT_SECTION_COUNT = 19,
-  LDPT_GET_INPUT_SECTION_TYPE = 20,
-  LDPT_GET_INPUT_SECTION_NAME = 21,
-  LDPT_GET_INPUT_SECTION_CONTENTS = 22,
-  LDPT_UPDATE_SECTION_ORDER = 23,
-  LDPT_ALLOW_SECTION_ORDERING = 24,
-  LDPT_GET_SYMBOLS_V2 = 25,
-  LDPT_ALLOW_UNIQUE_SEGMENT_FOR_SECTIONS = 26,
-  LDPT_UNIQUE_SEGMENT_FOR_SECTIONS = 27,
-  LDPT_GET_SYMBOLS_V3 = 28,
-  LDPT_GET_INPUT_SECTION_ALIGNMENT = 29,
-  LDPT_GET_INPUT_SECTION_SIZE = 30,
-  LDPT_REGISTER_NEW_INPUT_HOOK = 31,
-  LDPT_GET_WRAP_SYMBOLS = 32,
-  LDPT_ADD_SYMBOLS_V2 = 33
+  LDPT_NULL,
+  LDPT_API_VERSION,
+  LDPT_GOLD_VERSION,
+  LDPT_LINKER_OUTPUT,
+  LDPT_OPTION,
+  LDPT_REGISTER_CLAIM_FILE_HOOK,
+  LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK,
+  LDPT_REGISTER_CLEANUP_HOOK,
+  LDPT_ADD_SYMBOLS,
+  LDPT_GET_SYMBOLS,
+  LDPT_ADD_INPUT_FILE,
+  LDPT_MESSAGE,
+  LDPT_GET_INPUT_FILE,
+  LDPT_RELEASE_INPUT_FILE,
+  LDPT_ADD_INPUT_LIBRARY,
+  LDPT_OUTPUT_NAME,
+  LDPT_SET_EXTRA_LIBRARY_PATH,
+  LDPT_GNU_LD_VERSION,
+  LDPT_GET_VIEW,
+  LDPT_GET_INPUT_SECTION_COUNT,
+  LDPT_GET_INPUT_SECTION_TYPE,
+  LDPT_GET_INPUT_SECTION_NAME,
+  LDPT_GET_INPUT_SECTION_CONTENTS,
+  LDPT_UPDATE_SECTION_ORDER,
+  LDPT_ALLOW_SECTION_ORDERING,
+  LDPT_GET_SYMBOLS_V2,
+  LDPT_ALLOW_UNIQUE_SEGMENT_FOR_SECTIONS,
+  LDPT_UNIQUE_SEGMENT_FOR_SECTIONS,
+  LDPT_GET_SYMBOLS_V3,
+  LDPT_GET_INPUT_SECTION_ALIGNMENT,
+  LDPT_GET_INPUT_SECTION_SIZE,
+  LDPT_REGISTER_NEW_INPUT_HOOK,
+  LDPT_GET_WRAP_SYMBOLS,
+  LDPT_ADD_SYMBOLS_V2,
 };
 
 /* The plugin transfer vector.  */
diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c
index 33d49571d0e..47378435612 100644
--- a/lto-plugin/lto-plugin.c
+++ b/lto-plugin/lto-plugin.c
@@ -122,7 +122,7 @@ struct plugin_symtab
 struct plugin_objfile
 {
   int found;
-  int offload;
+  bool offload;
   simple_object_read *objfile;
   struct plugin_symtab *out;
   const struct ld_plugin_input_file *file;
@@ -205,7 +205,7 @@ static const char *link_output_name = NULL;
 
 /* This indicates link_output_name already contains the dot of the
    suffix, so we can skip it in extensions.  */
-static int skip_in_suffix = 0;
+static bool skip_in_suffix = false;
 
 /* The version of gold being used, or -1 if not gold.  The number is
    MAJOR * 100 + MINOR.  */
@@ -636,7 +636,8 @@ exec_lto_wrapper (char *argv[])
   /* Write argv to a file to avoid a command line that is too long
      Save the file locally on save-temps.  */
   const char *suffix = ".lto_wrapper_args";
-  suffix += skip_in_suffix;
+  if (skip_in_suffix)
+    suffix++;
   if (save_temps && link_output_name)
     arguments_file_name = concat (link_output_name, suffix, NULL);
   else
@@ -1139,7 +1140,7 @@ process_offload_section (void *data, const char *name, off_t offset, off_t len)
   if (startswith (name, ".gnu.offload_lto_.opts"))
     {
       struct plugin_objfile *obj = (struct plugin_objfile *) data;
-      obj->offload = 1;
+      obj->offload = true;
       return 0;
     }
 
@@ -1182,7 +1183,7 @@ claim_file_handler (const struct ld_plugin_input_file *file, int *claimed)
   *claimed = 0;
   obj.file = file;
   obj.found = 0;
-  obj.offload = 0;
+  obj.offload = false;
   obj.out = &lto_file.symtab;
   errmsg = NULL;
   obj.objfile = simple_object_start_read (file->fd, file->offset, LTO_SEGMENT_NAME,
@@ -1220,7 +1221,7 @@ claim_file_handler (const struct ld_plugin_input_file *file, int *claimed)
     simple_object_find_sections (obj.objfile, process_offload_section,
 				 &obj, &err);
 
-  if (obj.found == 0 && obj.offload == 0)
+  if (obj.found == 0 && !obj.offload)
     goto err;
 
   if (obj.found > 1)
@@ -1257,10 +1258,10 @@ claim_file_handler (const struct ld_plugin_input_file *file, int *claimed)
   /* If this is an LTO file without offload, and it is the first LTO file, save
      the pointer to the last offload file in the list.  Further offload LTO
      files will be inserted after it, if any.  */
-  if (*claimed && obj.offload == 0 && offload_files_last_lto == NULL)
+  if (*claimed && !obj.offload && offload_files_last_lto == NULL)
     offload_files_last_lto = offload_files_last;
 
-  if (obj.offload == 1)
+  if (obj.offload)
     {
       /* Add file to the list.  The order must be exactly the same as the final
 	 order after recompilation and linking, otherwise host and target tables
@@ -1547,7 +1548,7 @@ onload (struct ld_plugin_tv *tv)
 	  assert (escapes == 0);
 	  assert (ticks == oddticks);
 	  assert (q - link_output_name == len - 1);
-	  skip_in_suffix = 1;
+	  skip_in_suffix = true;
 	}
     }
 
-- 
2.36.0


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

* Re: [PATCH] LTO plugin: modernize a bit.
  2022-05-03 14:04 [PATCH] LTO plugin: modernize a bit Martin Liška
@ 2022-05-03 15:12 ` Jeff Law
  0 siblings, 0 replies; 6+ messages in thread
From: Jeff Law @ 2022-05-03 15:12 UTC (permalink / raw)
  To: gcc-patches



On 5/3/2022 8:04 AM, Martin Liška wrote:
> This is a follow up patch of something I sent last stage1.
> I'm not planning moving to C++, but I would like to see this patch
> go in.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed?
> Thanks,
> Martin
>
> include/ChangeLog:
>
> 	* plugin-api.h (enum ld_plugin_tag): Do not set implicit enum
> 	values.
>
> lto-plugin/ChangeLog:
>
> 	* lto-plugin.c (struct plugin_objfile): Use bool for offset
> 	field.
> 	(exec_lto_wrapper): Assign true/false to bool variables.
> 	(process_offload_section): Likewise.
> 	(claim_file_handler): Likewise.
> 	(onload): Likewise.
Whoops.  Was looking at the wrong patch earlier.

This is fine too :-)

Jeff


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

* Re: [PATCH] LTO plugin: modernize a bit.
  2022-01-05 11:06 Martin Liška
  2022-01-05 17:43 ` Jeff Law
@ 2022-01-18 11:59 ` Thomas Schwinge
  1 sibling, 0 replies; 6+ messages in thread
From: Thomas Schwinge @ 2022-01-18 11:59 UTC (permalink / raw)
  To: Martin Liška, gcc-patches

Hi!

On 2022-01-05T12:06:12+0100, Martin Liška <mliska@suse.cz> wrote:
> The patch is about small refactoring of the plugin.

Yay!

> include/ChangeLog:
>
>       * plugin-api.h (enum ld_plugin_tag): Do not set implicit enum
>       values.

I did wonder whether the original idea there would've been to fixate
these values, which are part of a public API/ABI?  (..., and thus, even
if the values don't change now if not assigning them explicitly, maybe
that should still be kept as-is, for robustness.)  But then, all other
'enum's in 'include/plugin-api.h' also don't assign explicit 'enum'
values, so probably there's indeed no reason for this one to be
different.


Grüße
 Thomas


> --- a/include/plugin-api.h
> +++ b/include/plugin-api.h
> @@ -487,40 +487,40 @@ enum ld_plugin_level
>
>   enum ld_plugin_tag
>   {
> -  LDPT_NULL = 0,
> -  LDPT_API_VERSION = 1,
> -  LDPT_GOLD_VERSION = 2,
> -  LDPT_LINKER_OUTPUT = 3,
> -  LDPT_OPTION = 4,
> -  LDPT_REGISTER_CLAIM_FILE_HOOK = 5,
> -  LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK = 6,
> -  LDPT_REGISTER_CLEANUP_HOOK = 7,
> -  LDPT_ADD_SYMBOLS = 8,
> -  LDPT_GET_SYMBOLS = 9,
> -  LDPT_ADD_INPUT_FILE = 10,
> -  LDPT_MESSAGE = 11,
> -  LDPT_GET_INPUT_FILE = 12,
> -  LDPT_RELEASE_INPUT_FILE = 13,
> -  LDPT_ADD_INPUT_LIBRARY = 14,
> -  LDPT_OUTPUT_NAME = 15,
> -  LDPT_SET_EXTRA_LIBRARY_PATH = 16,
> -  LDPT_GNU_LD_VERSION = 17,
> -  LDPT_GET_VIEW = 18,
> -  LDPT_GET_INPUT_SECTION_COUNT = 19,
> -  LDPT_GET_INPUT_SECTION_TYPE = 20,
> -  LDPT_GET_INPUT_SECTION_NAME = 21,
> -  LDPT_GET_INPUT_SECTION_CONTENTS = 22,
> -  LDPT_UPDATE_SECTION_ORDER = 23,
> -  LDPT_ALLOW_SECTION_ORDERING = 24,
> -  LDPT_GET_SYMBOLS_V2 = 25,
> -  LDPT_ALLOW_UNIQUE_SEGMENT_FOR_SECTIONS = 26,
> -  LDPT_UNIQUE_SEGMENT_FOR_SECTIONS = 27,
> -  LDPT_GET_SYMBOLS_V3 = 28,
> -  LDPT_GET_INPUT_SECTION_ALIGNMENT = 29,
> -  LDPT_GET_INPUT_SECTION_SIZE = 30,
> -  LDPT_REGISTER_NEW_INPUT_HOOK = 31,
> -  LDPT_GET_WRAP_SYMBOLS = 32,
> -  LDPT_ADD_SYMBOLS_V2 = 33
> +  LDPT_NULL,
> +  LDPT_API_VERSION,
> +  LDPT_GOLD_VERSION,
> +  LDPT_LINKER_OUTPUT,
> +  LDPT_OPTION,
> +  LDPT_REGISTER_CLAIM_FILE_HOOK,
> +  LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK,
> +  LDPT_REGISTER_CLEANUP_HOOK,
> +  LDPT_ADD_SYMBOLS,
> +  LDPT_GET_SYMBOLS,
> +  LDPT_ADD_INPUT_FILE,
> +  LDPT_MESSAGE,
> +  LDPT_GET_INPUT_FILE,
> +  LDPT_RELEASE_INPUT_FILE,
> +  LDPT_ADD_INPUT_LIBRARY,
> +  LDPT_OUTPUT_NAME,
> +  LDPT_SET_EXTRA_LIBRARY_PATH,
> +  LDPT_GNU_LD_VERSION,
> +  LDPT_GET_VIEW,
> +  LDPT_GET_INPUT_SECTION_COUNT,
> +  LDPT_GET_INPUT_SECTION_TYPE,
> +  LDPT_GET_INPUT_SECTION_NAME,
> +  LDPT_GET_INPUT_SECTION_CONTENTS,
> +  LDPT_UPDATE_SECTION_ORDER,
> +  LDPT_ALLOW_SECTION_ORDERING,
> +  LDPT_GET_SYMBOLS_V2,
> +  LDPT_ALLOW_UNIQUE_SEGMENT_FOR_SECTIONS,
> +  LDPT_UNIQUE_SEGMENT_FOR_SECTIONS,
> +  LDPT_GET_SYMBOLS_V3,
> +  LDPT_GET_INPUT_SECTION_ALIGNMENT,
> +  LDPT_GET_INPUT_SECTION_SIZE,
> +  LDPT_REGISTER_NEW_INPUT_HOOK,
> +  LDPT_GET_WRAP_SYMBOLS,
> +  LDPT_ADD_SYMBOLS_V2,
>   };

-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

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

* Re: [PATCH] LTO plugin: modernize a bit.
  2022-01-05 17:43 ` Jeff Law
@ 2022-01-06 11:03   ` Martin Liška
  0 siblings, 0 replies; 6+ messages in thread
From: Martin Liška @ 2022-01-06 11:03 UTC (permalink / raw)
  To: Jeff Law, gcc-patches

On 1/5/22 18:43, Jeff Law wrote:
> But the timing isn't great.  We're in stage3 and presumably moving into stage4 shortly. Shouldn't this wait until stage1 re-opens?

Agree, I'm going to prepare the changes for GCC 13, same as LTO plugin support for ld.mold.

Cheers,
Martin

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

* Re: [PATCH] LTO plugin: modernize a bit.
  2022-01-05 11:06 Martin Liška
@ 2022-01-05 17:43 ` Jeff Law
  2022-01-06 11:03   ` Martin Liška
  2022-01-18 11:59 ` Thomas Schwinge
  1 sibling, 1 reply; 6+ messages in thread
From: Jeff Law @ 2022-01-05 17:43 UTC (permalink / raw)
  To: Martin Liška, gcc-patches



On 1/5/2022 4:06 AM, Martin Liška wrote:
> The patch is about small refactoring of the plugin.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed?
> Thanks,
> Martin
>
> include/ChangeLog:
>
>     * plugin-api.h (enum ld_plugin_tag): Do not set implicit enum
>     values.
>
> lto-plugin/ChangeLog:
>
>     * lto-plugin.c (struct plugin_objfile): Use bool for offset
>     field.
>     (exec_lto_wrapper): Assign true/false to bool variables.
>     (process_offload_section): Likewise.
>     (claim_file_handler): Likewise.
>     (onload): Likewise.
I don't see anything controversial in here.  But the timing isn't 
great.  We're in stage3 and presumably moving into stage4 shortly. 
Shouldn't this wait until stage1 re-opens?

jeff


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

* [PATCH] LTO plugin: modernize a bit.
@ 2022-01-05 11:06 Martin Liška
  2022-01-05 17:43 ` Jeff Law
  2022-01-18 11:59 ` Thomas Schwinge
  0 siblings, 2 replies; 6+ messages in thread
From: Martin Liška @ 2022-01-05 11:06 UTC (permalink / raw)
  To: gcc-patches

The patch is about small refactoring of the plugin.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

include/ChangeLog:

	* plugin-api.h (enum ld_plugin_tag): Do not set implicit enum
	values.

lto-plugin/ChangeLog:

	* lto-plugin.c (struct plugin_objfile): Use bool for offset
	field.
	(exec_lto_wrapper): Assign true/false to bool variables.
	(process_offload_section): Likewise.
	(claim_file_handler): Likewise.
	(onload): Likewise.
---
  include/plugin-api.h    | 68 ++++++++++++++++++++---------------------
  lto-plugin/lto-plugin.c | 19 ++++++------
  2 files changed, 44 insertions(+), 43 deletions(-)

diff --git a/include/plugin-api.h b/include/plugin-api.h
index 4e12c0320d6..8aebe2ff267 100644
--- a/include/plugin-api.h
+++ b/include/plugin-api.h
@@ -487,40 +487,40 @@ enum ld_plugin_level
  
  enum ld_plugin_tag
  {
-  LDPT_NULL = 0,
-  LDPT_API_VERSION = 1,
-  LDPT_GOLD_VERSION = 2,
-  LDPT_LINKER_OUTPUT = 3,
-  LDPT_OPTION = 4,
-  LDPT_REGISTER_CLAIM_FILE_HOOK = 5,
-  LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK = 6,
-  LDPT_REGISTER_CLEANUP_HOOK = 7,
-  LDPT_ADD_SYMBOLS = 8,
-  LDPT_GET_SYMBOLS = 9,
-  LDPT_ADD_INPUT_FILE = 10,
-  LDPT_MESSAGE = 11,
-  LDPT_GET_INPUT_FILE = 12,
-  LDPT_RELEASE_INPUT_FILE = 13,
-  LDPT_ADD_INPUT_LIBRARY = 14,
-  LDPT_OUTPUT_NAME = 15,
-  LDPT_SET_EXTRA_LIBRARY_PATH = 16,
-  LDPT_GNU_LD_VERSION = 17,
-  LDPT_GET_VIEW = 18,
-  LDPT_GET_INPUT_SECTION_COUNT = 19,
-  LDPT_GET_INPUT_SECTION_TYPE = 20,
-  LDPT_GET_INPUT_SECTION_NAME = 21,
-  LDPT_GET_INPUT_SECTION_CONTENTS = 22,
-  LDPT_UPDATE_SECTION_ORDER = 23,
-  LDPT_ALLOW_SECTION_ORDERING = 24,
-  LDPT_GET_SYMBOLS_V2 = 25,
-  LDPT_ALLOW_UNIQUE_SEGMENT_FOR_SECTIONS = 26,
-  LDPT_UNIQUE_SEGMENT_FOR_SECTIONS = 27,
-  LDPT_GET_SYMBOLS_V3 = 28,
-  LDPT_GET_INPUT_SECTION_ALIGNMENT = 29,
-  LDPT_GET_INPUT_SECTION_SIZE = 30,
-  LDPT_REGISTER_NEW_INPUT_HOOK = 31,
-  LDPT_GET_WRAP_SYMBOLS = 32,
-  LDPT_ADD_SYMBOLS_V2 = 33
+  LDPT_NULL,
+  LDPT_API_VERSION,
+  LDPT_GOLD_VERSION,
+  LDPT_LINKER_OUTPUT,
+  LDPT_OPTION,
+  LDPT_REGISTER_CLAIM_FILE_HOOK,
+  LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK,
+  LDPT_REGISTER_CLEANUP_HOOK,
+  LDPT_ADD_SYMBOLS,
+  LDPT_GET_SYMBOLS,
+  LDPT_ADD_INPUT_FILE,
+  LDPT_MESSAGE,
+  LDPT_GET_INPUT_FILE,
+  LDPT_RELEASE_INPUT_FILE,
+  LDPT_ADD_INPUT_LIBRARY,
+  LDPT_OUTPUT_NAME,
+  LDPT_SET_EXTRA_LIBRARY_PATH,
+  LDPT_GNU_LD_VERSION,
+  LDPT_GET_VIEW,
+  LDPT_GET_INPUT_SECTION_COUNT,
+  LDPT_GET_INPUT_SECTION_TYPE,
+  LDPT_GET_INPUT_SECTION_NAME,
+  LDPT_GET_INPUT_SECTION_CONTENTS,
+  LDPT_UPDATE_SECTION_ORDER,
+  LDPT_ALLOW_SECTION_ORDERING,
+  LDPT_GET_SYMBOLS_V2,
+  LDPT_ALLOW_UNIQUE_SEGMENT_FOR_SECTIONS,
+  LDPT_UNIQUE_SEGMENT_FOR_SECTIONS,
+  LDPT_GET_SYMBOLS_V3,
+  LDPT_GET_INPUT_SECTION_ALIGNMENT,
+  LDPT_GET_INPUT_SECTION_SIZE,
+  LDPT_REGISTER_NEW_INPUT_HOOK,
+  LDPT_GET_WRAP_SYMBOLS,
+  LDPT_ADD_SYMBOLS_V2,
  };
  
  /* The plugin transfer vector.  */
diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c
index c9c048d3631..0147b1b9667 100644
--- a/lto-plugin/lto-plugin.c
+++ b/lto-plugin/lto-plugin.c
@@ -122,7 +122,7 @@ struct plugin_symtab
  struct plugin_objfile
  {
    int found;
-  int offload;
+  bool offload;
    simple_object_read *objfile;
    struct plugin_symtab *out;
    const struct ld_plugin_input_file *file;
@@ -205,7 +205,7 @@ static const char *link_output_name = NULL;
  
  /* This indicates link_output_name already contains the dot of the
     suffix, so we can skip it in extensions.  */
-static int skip_in_suffix = 0;
+static bool skip_in_suffix = false;
  
  /* The version of gold being used, or -1 if not gold.  The number is
     MAJOR * 100 + MINOR.  */
@@ -636,7 +636,8 @@ exec_lto_wrapper (char *argv[])
    /* Write argv to a file to avoid a command line that is too long
       Save the file locally on save-temps.  */
    const char *suffix = ".lto_wrapper_args";
-  suffix += skip_in_suffix;
+  if (skip_in_suffix)
+    suffix++;
    if (save_temps && link_output_name)
      arguments_file_name = concat (link_output_name, suffix, NULL);
    else
@@ -1132,7 +1133,7 @@ process_offload_section (void *data, const char *name, off_t offset, off_t len)
    if (startswith (name, ".gnu.offload_lto_.opts"))
      {
        struct plugin_objfile *obj = (struct plugin_objfile *) data;
-      obj->offload = 1;
+      obj->offload = true;
        return 0;
      }
  
@@ -1175,7 +1176,7 @@ claim_file_handler (const struct ld_plugin_input_file *file, int *claimed)
    *claimed = 0;
    obj.file = file;
    obj.found = 0;
-  obj.offload = 0;
+  obj.offload = false;
    obj.out = &lto_file.symtab;
    errmsg = NULL;
    obj.objfile = simple_object_start_read (file->fd, file->offset, LTO_SEGMENT_NAME,
@@ -1213,7 +1214,7 @@ claim_file_handler (const struct ld_plugin_input_file *file, int *claimed)
      simple_object_find_sections (obj.objfile, process_offload_section,
  				 &obj, &err);
  
-  if (obj.found == 0 && obj.offload == 0)
+  if (obj.found == 0 && !obj.offload)
      goto err;
  
    if (obj.found > 1)
@@ -1250,10 +1251,10 @@ claim_file_handler (const struct ld_plugin_input_file *file, int *claimed)
    /* If this is an LTO file without offload, and it is the first LTO file, save
       the pointer to the last offload file in the list.  Further offload LTO
       files will be inserted after it, if any.  */
-  if (*claimed && obj.offload == 0 && offload_files_last_lto == NULL)
+  if (*claimed && !obj.offload && offload_files_last_lto == NULL)
      offload_files_last_lto = offload_files_last;
  
-  if (obj.offload == 1)
+  if (obj.offload)
      {
        /* Add file to the list.  The order must be exactly the same as the final
  	 order after recompilation and linking, otherwise host and target tables
@@ -1540,7 +1541,7 @@ onload (struct ld_plugin_tv *tv)
  	  assert (escapes == 0);
  	  assert (ticks == oddticks);
  	  assert (q - link_output_name == len - 1);
-	  skip_in_suffix = 1;
+	  skip_in_suffix = true;
  	}
      }
  
-- 
2.34.1


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

end of thread, other threads:[~2022-05-03 15:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-03 14:04 [PATCH] LTO plugin: modernize a bit Martin Liška
2022-05-03 15:12 ` Jeff Law
  -- strict thread matches above, loose matches on Subject: below --
2022-01-05 11:06 Martin Liška
2022-01-05 17:43 ` Jeff Law
2022-01-06 11:03   ` Martin Liška
2022-01-18 11:59 ` Thomas Schwinge

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