diff options
author | David Chase <drchase@google.com> | 2021-03-31 22:51:44 -0400 |
---|---|---|
committer | David Chase <drchase@google.com> | 2021-04-01 15:50:43 +0000 |
commit | 45ca9ef5c1235a80ceffca459cbf1bd47032b35f (patch) | |
tree | 8f3193883aa0016b52e8f7ae33eaf8b0f79b492b /src/cmd/compile/internal/abi/abiutils.go | |
parent | e6ac2df2b198f583780277a7cf96e3b0b61fe0a1 (diff) | |
download | go-45ca9ef5c1235a80ceffca459cbf1bd47032b35f.tar.gz go-45ca9ef5c1235a80ceffca459cbf1bd47032b35f.zip |
cmd/compile: fix register/offset calculation for trailing empty field case.
Includes test.
Long term, need to make the offending code be more in terms
of official types package offsets, instead of duplicating that
logic.
For #40724.
Change-Id: Id33a153f10aed3289cc48d1f99a8e0f6ece9474d
Reviewed-on: https://go-review.googlesource.com/c/go/+/306469
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/cmd/compile/internal/abi/abiutils.go')
-rw-r--r-- | src/cmd/compile/internal/abi/abiutils.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/abi/abiutils.go b/src/cmd/compile/internal/abi/abiutils.go index 56e008830f..50a818c025 100644 --- a/src/cmd/compile/internal/abi/abiutils.go +++ b/src/cmd/compile/internal/abi/abiutils.go @@ -211,8 +211,11 @@ func appendParamOffsets(offsets []int64, at int64, t *types.Type) ([]int64, int6 offsets, at = appendParamOffsets(offsets, at, t.Elem()) } case types.TSTRUCT: - for _, f := range t.FieldSlice() { + for i, f := range t.FieldSlice() { offsets, at = appendParamOffsets(offsets, at, f.Type) + if f.Type.Width == 0 && i == t.NumFields()-1 { + at++ // last field has zero width + } } at = align(at, t) // type size is rounded up to its alignment case types.TSLICE: |