1
0
mirror of https://github.com/golang/go synced 2024-11-18 20:24:41 -07:00

go/analysis/passes/asmdecl: fix array offsets

Array offsets in recursive structures do not include the accumulated
offset. This diff fixes the mistake and adds a test.

Fixes golang/go#29318

Change-Id: Iaa2a2f9404e4ed0e38b87e5e041709c1a8e25809
Reviewed-on: https://go-review.googlesource.com/c/154665
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
Michael McLoughlin 2018-12-18 01:36:47 -08:00 committed by Josh Bleecher Snyder
parent 13ba8ad772
commit bbbd9518e8
3 changed files with 8 additions and 1 deletions

View File

@ -490,7 +490,7 @@ func appendComponentsRecursive(arch *asmArch, t types.Type, cc []component, suff
offsets := arch.sizes.Offsetsof(fields)
elemoff := int(offsets[1])
for i := 0; i < int(tu.Len()); i++ {
cc = appendComponentsRecursive(arch, elem, cc, suffix+"_"+strconv.Itoa(i), i*elemoff)
cc = appendComponentsRecursive(arch, elem, cc, suffix+"_"+strconv.Itoa(i), off+i*elemoff)
}
}

View File

@ -41,6 +41,7 @@ func wrapper(x int)
func f15271() (x uint32)
func f17584(x float32, y complex64)
func f29318(x [2][2]uint64)
func noframe1(x int32)
func noframe2(x int32)

View File

@ -312,3 +312,9 @@ TEXT ·f17584(SB), NOSPLIT, $12
MOVSS y_real+4(FP), X0
MOVSS y_imag+8(FP), X0
RET
// issue 29318
TEXT ·f29318(SB), NOSPLIT, $32
MOVQ x_0_1+8(FP), AX
MOVQ x_1_1+24(FP), CX
RET