Source file test/codegen/moveload.go

     1  // asmcheck
     2  
     3  // Copyright 2026 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  package codegen
     8  
     9  // From issue #77720: cmd/compile: field access on struct-returning method copies entire struct
    10  
    11  type moveLoadBig struct {
    12  	typ   int8
    13  	index int64
    14  	str   string
    15  	pkgID string
    16  }
    17  
    18  type moveLoadHandle[T any] struct {
    19  	value *T
    20  }
    21  
    22  func (h moveLoadHandle[T]) Value() T { return *h.value }
    23  
    24  type moveLoadS struct {
    25  	h moveLoadHandle[moveLoadBig]
    26  }
    27  
    28  func moveLoadFieldViaValue(s moveLoadS) int8 {
    29  	// amd64:-`MOVUPS`
    30  	// amd64:`MOVBLZX`
    31  	return s.h.Value().typ
    32  }
    33  
    34  func moveLoadFieldViaValueInline(ss []moveLoadS, i int) int8 {
    35  	// amd64:-`MOVUPS`
    36  	// amd64:`MOVBLZX`
    37  	return ss[i&7].h.Value().typ
    38  }
    39  

View as plain text