From 77973863c351b162d68723439fc56fb054e917b2 Mon Sep 17 00:00:00 2001 From: David Chase Date: Tue, 9 Feb 2021 15:14:43 -0500 Subject: 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 Run-TryBot: David Chase TryBot-Result: Go Bot Reviewed-by: Cherry Zhang --- src/cmd/compile/internal/types/size.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/cmd/compile/internal/types/size.go') 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, -- cgit v1.2.3-54-g00ecf