Source file test/fixedbugs/dse_move_auxint.go

     1  // run
     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  // Dead-store elimination must use the AuxInt byte count of OpMove,
     8  // not the size of its Aux type. The "inline runtime.memmove" rewrite
     9  // emits Move {uint8} [N]; if DSE treats that as a 1-byte write, a
    10  // trailing 1-byte store appears to fully shadow it and the move is
    11  // incorrectly deleted.
    12  
    13  package main
    14  
    15  import "fmt"
    16  
    17  //go:noinline
    18  func f() [8]byte {
    19  	str := "ABCDEFGH"
    20  	dst := make([]byte, len(str))
    21  	copy(dst, str)
    22  	dst[0] = 99
    23  	return [8]byte(dst)
    24  }
    25  
    26  func main() {
    27  	got := f()
    28  	want := [8]byte{99, 'B', 'C', 'D', 'E', 'F', 'G', 'H'}
    29  	if got != want {
    30  		panic(fmt.Sprintf("got %v, want %v", got, want))
    31  	}
    32  }
    33  

View as plain text