From 4c9989a3608d410d1408ce26958c6388da24e553 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20M=C3=B6hrmann?= Date: Tue, 29 Aug 2017 21:16:28 +0200 Subject: [PATCH] cmd/compile: avoid padding for indirect map key or value on amd64p32 Padding needed for map buckets is dependent on the types used to construct the map bucket. In case of indirect keys or values pointers are used in the map bucket to the keys or values. Change the map bucket padding calculation to take the alignment of the key and value types used to construct the map bucket into account instead of the original key and value type. Since pointers are always 32bit aligned on amd64p32 this prevents adding unneeded padding in case the key or value would have needed 64bit alignment without indirect referencing. Change-Id: I7943448e882d269b5cff7e921a2a6f3430c50878 Reviewed-on: https://go-review.googlesource.com/60030 Reviewed-by: Keith Randall --- src/cmd/compile/internal/gc/reflect.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/compile/internal/gc/reflect.go b/src/cmd/compile/internal/gc/reflect.go index 9d9b43152e..3e1f26b866 100644 --- a/src/cmd/compile/internal/gc/reflect.go +++ b/src/cmd/compile/internal/gc/reflect.go @@ -146,7 +146,7 @@ func mapbucket(t *types.Type) *types.Type { // so if the struct needs 64-bit padding (because a key or value does) // then it would end with an extra 32-bit padding field. // Preempt that by emitting the padding here. - if int(t.Val().Align) > Widthptr || int(t.Key().Align) > Widthptr { + if int(valtype.Align) > Widthptr || int(keytype.Align) > Widthptr { field = append(field, makefield("pad", types.Types[TUINTPTR])) } -- 2.50.0