Source file test/abi/too_big_to_ssa.go

     1  // run
     2  
     3  //go:build !wasm
     4  
     5  // Copyright 2021 The Go Authors. All rights reserved.
     6  // Use of this source code is governed by a BSD-style
     7  // license that can be found in the LICENSE file.
     8  
     9  package main
    10  
    11  import (
    12  	"fmt"
    13  )
    14  
    15  var sink *string
    16  
    17  type toobig struct {
    18  	// 6 words will not SSA but will fit in registers
    19  	a, b, c string
    20  }
    21  
    22  //go:registerparams
    23  //go:noinline
    24  func H(x toobig) string {
    25  	return x.a + " " + x.b + " " + x.c
    26  }
    27  
    28  //go:registerparams
    29  //go:noinline
    30  func I(a, b, c string) toobig {
    31  	return toobig{a, b, c}
    32  }
    33  
    34  func main() {
    35  	s := H(toobig{"Hello", "there,", "World"})
    36  	gotVsWant(s, "Hello there, World")
    37  	fmt.Println(s)
    38  	t := H(I("Ahoy", "there,", "Matey"))
    39  	gotVsWant(t, "Ahoy there, Matey")
    40  	fmt.Println(t)
    41  }
    42  
    43  func gotVsWant(got, want string) {
    44  	if got != want {
    45  		fmt.Printf("FAIL, got %s, wanted %s\n", got, want)
    46  	}
    47  }
    48  

View as plain text