public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-6147] compiler, libgo: don't pad sparc64-linux epollevent
@ 2021-12-29 23:53 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2021-12-29 23:53 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:62c3f75fd29e93054f3aeb8a623fd52c98c3db0b

commit r12-6147-g62c3f75fd29e93054f3aeb8a623fd52c98c3db0b
Author: Ian Lance Taylor <iant@golang.org>
Date:   Wed Dec 29 15:08:32 2021 -0800

    compiler, libgo: don't pad sparc64-linux epollevent
    
    Change the compiler to not add zero padding because of zero-sized
    fields named "_", since those can't be referenced anyhow.
    
    Change the sparc-linux64 epollevent struct to name the alignment
    field "_", to avoid zero padding.
    
    Fixes PR go/103847
    
            PR go/103847
            * godump.c (go_force_record_alignment): Name the alignment
            field "_".
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/374914

Diff:
---
 gcc/go/gofrontend/MERGE    |  2 +-
 gcc/go/gofrontend/types.cc | 15 ++++++++++++---
 gcc/godump.c               |  2 +-
 libgo/mkrsysinfo.sh        |  2 +-
 4 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 05e47ec3fa9..2d04f4b01c0 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-3e9f4ee16683883ccfb8661d99318c74bb7a4bef
+d3be41f0a1fca20e241e1db62b4b0f5262caac55
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc
index 0f66661937c..57c02a97ef0 100644
--- a/gcc/go/gofrontend/types.cc
+++ b/gcc/go/gofrontend/types.cc
@@ -6454,9 +6454,18 @@ get_backend_struct_fields(Gogo* gogo, Struct_type* type, bool use_placeholder,
 			     ? p->type()->get_backend_placeholder(gogo)
 			     : p->type()->get_backend(gogo));
       (*bfields)[i].location = p->location();
-      lastsize = gogo->backend()->type_size((*bfields)[i].btype);
-      if (lastsize != 0)
-        saw_nonzero = true;
+      int64_t size = gogo->backend()->type_size((*bfields)[i].btype);
+      if (size != 0)
+	saw_nonzero = true;
+
+      if (size > 0 || !Gogo::is_sink_name(p->field_name()))
+	lastsize = size;
+      else
+	{
+	  // There is an unreferenceable field of zero size.  This
+	  // doesn't affect whether we may need zero padding, so leave
+	  // lastsize unchanged.
+	}
     }
   go_assert(i == fields->size());
   if (saw_nonzero && lastsize == 0 && !type->is_results_struct())
diff --git a/gcc/godump.c b/gcc/godump.c
index a50aef1f5fa..f016989c93f 100644
--- a/gcc/godump.c
+++ b/gcc/godump.c
@@ -651,7 +651,7 @@ go_force_record_alignment (struct obstack *ob, const char *type_string,
 			   unsigned int index, const char *error_string)
 {
   index = go_append_artificial_name (ob, index);
-  obstack_grow (ob, "_align ", 7);
+  obstack_grow (ob, "_ ", 2);
   if (type_string == NULL)
     obstack_grow (ob, error_string, strlen (error_string));
   else
diff --git a/libgo/mkrsysinfo.sh b/libgo/mkrsysinfo.sh
index 18643370645..be150905f91 100755
--- a/libgo/mkrsysinfo.sh
+++ b/libgo/mkrsysinfo.sh
@@ -98,7 +98,7 @@ if grep '^const _epoll_data_offset ' ${OUT} >/dev/null 2>&1; then
       echo 'type epollevent struct { events uint32; data [8]byte }' >> ${OUT}
   elif test "$val" = "8"; then
       if test "$GOARCH" = "sparc64" -a "$GOOS" = "linux"; then
-          echo 'type epollevent struct { events uint32; pad [4]byte; data [8]byte; _align [0]int64 }' >> ${OUT}
+          echo 'type epollevent struct { events uint32; pad [4]byte; data [8]byte; _ [0]int64 }' >> ${OUT}
       else
           echo 'type epollevent struct { events uint32; pad [4]byte; data [8]byte }' >> ${OUT}
       fi


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-12-29 23:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-29 23:53 [gcc r12-6147] compiler, libgo: don't pad sparc64-linux epollevent Ian Lance Taylor

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