]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix parameter offset calculation
authorCherry Zhang <cherryyz@google.com>
Thu, 1 Apr 2021 00:02:26 +0000 (20:02 -0400)
committerDavid Chase <drchase@google.com>
Thu, 1 Apr 2021 01:26:29 +0000 (01:26 +0000)
commit5f646f0a984d43a2e9e99a1338145a862fef425e
treef1e481ce3c4a4f613428ebbe78737e26e84264d7
parentec721d92bf35cd47543acf6792acd474fdd39446
cmd/compile: fix parameter offset calculation

For struct like { { a int64; b int16 }; c int32 }, on 64-bit
machines the offset of c is 16, as the inner struct takes 16
bytes because we round up type size to its alignment. Update the
abi package's offset calculation to include this.

We only need to do this for struct type, because for all other
types its size is naturally aligned.

TODO: add a test.

Change-Id: I0c661768cb1ed3cb409b20a88b7e23e059f8e3e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/306449
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/abi/abiutils.go