1
0
mirror of https://github.com/golang/go synced 2024-11-23 20:30:04 -07:00
go/test/fixedbugs/issue13171.go
Keith Randall ffb20631fc runtime: teach peephole optimizer that duffcopy clobbers X0
Duffcopy now uses X0, as of 5cf281a.  Teach the peephole
optimizer that duffcopy clobbers X0 so that it does not
rename registers use X0 across the duffcopy instruction.

Fixes #13171

Change-Id: I389cbf1982cb6eb2f51e6152ac96736a8589f085
Reviewed-on: https://go-review.googlesource.com/16715
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
2015-11-06 15:11:42 +00:00

35 lines
589 B
Go

// run
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
// Make sure the compiler knows that DUFFCOPY clobbers X0
import "fmt"
//go:noinline
func f(x float64) float64 {
// y is allocated to X0
y := x + 5
// marshals z before y. Marshalling z
// calls DUFFCOPY.
return g(z, y)
}
//go:noinline
func g(b [64]byte, y float64) float64 {
return y
}
var z [64]byte
func main() {
got := f(5)
if got != 10 {
panic(fmt.Sprintf("want 10, got %f", got))
}
}