aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types/size.go
diff options
context:
space:
mode:
authorDavid Chase <drchase@google.com>2021-02-09 15:14:43 -0500
committerDavid Chase <drchase@google.com>2021-03-03 01:45:33 +0000
commit77973863c351b162d68723439fc56fb054e917b2 (patch)
tree690743127dd11a65f9487824a8e4dc8d72f658a5 /src/cmd/compile/internal/types/size.go
parentaea1259a7288d71736273b494e60bd424ea1946c (diff)
downloadgo-77973863c351b162d68723439fc56fb054e917b2.tar.gz
go-77973863c351b162d68723439fc56fb054e917b2.zip
cmd/compile: use abiutils for all rcvr/in/out frame offsets.
types thought it knew how to do this, but that's a lie, because types doesn't know what the ABI is. includes extra checking to help prevent things from accidentally working if they need to be changed but aren't. For #40724. Change-Id: I166cd948f262344b7bebde6a2c25e7a7f878bbfb Reviewed-on: https://go-review.googlesource.com/c/go/+/293393 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types/size.go')
-rw-r--r--src/cmd/compile/internal/types/size.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/types/size.go b/src/cmd/compile/internal/types/size.go
index 799cf3a1f6..4c7378560c 100644
--- a/src/cmd/compile/internal/types/size.go
+++ b/src/cmd/compile/internal/types/size.go
@@ -141,6 +141,8 @@ func expandiface(t *Type) {
}
func calcStructOffset(errtype *Type, t *Type, o int64, flag int) int64 {
+ // flag is 0 (receiver), 1 (actual struct), or RegSize (in/out parameters)
+ isStruct := flag == 1
starto := o
maxalign := int32(flag)
if maxalign < 1 {
@@ -161,7 +163,9 @@ func calcStructOffset(errtype *Type, t *Type, o int64, flag int) int64 {
if f.Type.Align > 0 {
o = Rnd(o, int64(f.Type.Align))
}
- f.Offset = o
+ if isStruct { // For receiver/args/results, depends on ABI
+ f.Offset = o
+ }
if f.Nname != nil {
// addrescapes has similar code to update these offsets.
// Usually addrescapes runs after calcStructOffset,