1
0
mirror of https://github.com/golang/go synced 2024-11-08 05:26:15 -07:00

cmd/compile/internal: loop opt

Change-Id: I5fe767237b8046934e9b0f33bd3dafabdb727dd6
GitHub-Last-Rev: 94fea3d572
GitHub-Pull-Request: golang/go#44384
Reviewed-on: https://go-review.googlesource.com/c/go/+/293809
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
cui 2021-02-18 17:51:24 +00:00 committed by Robert Griesemer
parent 1391d4142c
commit 094048b938

View File

@ -624,9 +624,11 @@ func PtrDataSize(t *Type) int64 {
case TSTRUCT:
// Find the last field that has pointers.
var lastPtrField *Field
for _, t1 := range t.Fields().Slice() {
if t1.Type.HasPointers() {
lastPtrField = t1
fs := t.Fields().Slice()
for i := len(fs) - 1; i >= 0; i-- {
if fs[i].Type.HasPointers() {
lastPtrField = fs[i]
break
}
}
return lastPtrField.Offset + PtrDataSize(lastPtrField.Type)