diff mbox series

Simplify LTO section format.

Message ID c6dc2f90-0985-7250-4ff0-5f0bc8c69638@suse.cz
State New
Headers show
Series Simplify LTO section format. | expand

Commit Message

Martin Liška July 17, 2019, 10:32 a.m. UTC
Hi.

The patch is about simplified LTO ELF section header where
want to make public fields major_version, minor_version and
slim_object. The rest is implementation defined by GCC.

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

Ready to be installed?
Thanks,
Martin

gcc/ChangeLog:

2019-07-15  Martin Liska  <mliska@suse.cz>

	* lto-section-in.c (lto_get_section_data):
	Use new function get_compression.
	* lto-streamer-out.c (produce_lto_section): Use
	set_compression to encode compression algorithm.
	* lto-streamer.h (struct lto_section): Do not
	use bitfields in the format.
---
 gcc/lto-section-in.c   |  3 ++-
 gcc/lto-streamer-out.c |  3 ++-
 gcc/lto-streamer.h     | 19 ++++++++++++++++---
 3 files changed, 20 insertions(+), 5 deletions(-)

Comments

Jeff Law July 21, 2019, 8:02 p.m. UTC | #1
On 7/17/19 4:32 AM, Martin Liška wrote:
> Hi.
> 
> The patch is about simplified LTO ELF section header where
> want to make public fields major_version, minor_version and
> slim_object. The rest is implementation defined by GCC.
> 
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
> 
> Ready to be installed?
> Thanks,
> Martin
> 
> gcc/ChangeLog:
> 
> 2019-07-15  Martin Liska  <mliska@suse.cz>
> 
> 	* lto-section-in.c (lto_get_section_data):
> 	Use new function get_compression.
> 	* lto-streamer-out.c (produce_lto_section): Use
> 	set_compression to encode compression algorithm.
> 	* lto-streamer.h (struct lto_section): Do not
> 	use bitfields in the format.
> ---
>  gcc/lto-section-in.c   |  3 ++-
>  gcc/lto-streamer-out.c |  3 ++-
>  gcc/lto-streamer.h     | 19 ++++++++++++++++---
>  3 files changed, 20 insertions(+), 5 deletions(-)
> 
> 
OK
jeff
diff mbox series

Patch

diff --git a/gcc/lto-section-in.c b/gcc/lto-section-in.c
index 4c2870176ae..0bdcf62b1de 100644
--- a/gcc/lto-section-in.c
+++ b/gcc/lto-section-in.c
@@ -161,7 +161,8 @@  lto_get_section_data (struct lto_file_decl_data *file_data,
 
       stream = lto_start_uncompression (lto_append_data, &buffer);
       lto_uncompress_block (stream, data, *len);
-      lto_end_uncompression (stream, file_data->lto_section_header.compression);
+      lto_end_uncompression (stream,
+			     file_data->lto_section_header.get_compression ());
 
       *len = buffer.length - header_length;
       data = buffer.data + header_length;
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index 35dcae4d589..e0881cf57af 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -2403,7 +2403,8 @@  produce_lto_section ()
 
   bool slim_object = flag_generate_lto && !flag_fat_lto_objects;
   lto_section s
-    = { LTO_major_version, LTO_minor_version, slim_object, compression, 0 };
+    = { LTO_major_version, LTO_minor_version, slim_object, 0 };
+  s.set_compression (compression);
   lto_write_data (&s, sizeof s);
   lto_end_section ();
   destroy_output_block (ob);
diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h
index 3c35d8a3f9a..bf755a64141 100644
--- a/gcc/lto-streamer.h
+++ b/gcc/lto-streamer.h
@@ -394,9 +394,22 @@  struct lto_section
 {
   int16_t major_version;
   int16_t minor_version;
-  unsigned char slim_object: 1;
-  lto_compression compression: 4;
-  int32_t reserved0: 27;
+  unsigned char slim_object;
+
+  /* Flags is a private field that is not defined publicly.  */
+  uint16_t flags;
+
+  /* Set compression to FLAGS.  */
+  inline void set_compression (lto_compression c)
+  {
+    flags = c;
+  }
+
+  /* Get compression from FLAGS.  */
+  inline lto_compression get_compression ()
+  {
+    return (lto_compression) flags;
+  }
 };
 
 STATIC_ASSERT (sizeof (lto_section) == 8);