From 62c3f75fd29e93054f3aeb8a623fd52c98c3db0b Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 29 Dec 2021 15:08:32 -0800 Subject: 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 --- gcc/go/gofrontend/MERGE | 2 +- gcc/go/gofrontend/types.cc | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'gcc/go') diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 05e47ec..2d04f4b 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 0f66661..57c02a9 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()) -- cgit v1.1