From d822ffebc59d27190ac145a71c726dad35769225 Mon Sep 17 00:00:00 2001 From: Egon Elbre Date: Wed, 24 Feb 2021 21:08:52 +0200 Subject: [PATCH] test: fix inline.go test for linux-amd64-noopt math.Float32bits was not being inlined across package boundaries. Create a private func that can be inlined with -l. Change-Id: Ic50bf4727dd8ade09d011eb204006b7ee88db34a Reviewed-on: https://go-review.googlesource.com/c/go/+/295989 Reviewed-by: Josh Bleecher Snyder Reviewed-by: Bryan C. Mills Reviewed-by: Keith Randall Trust: Josh Bleecher Snyder Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot --- test/inline.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/test/inline.go b/test/inline.go index 44c746b2823..bc23768d016 100644 --- a/test/inline.go +++ b/test/inline.go @@ -10,7 +10,6 @@ package foo import ( - "math" "runtime" "unsafe" ) @@ -267,12 +266,18 @@ func gd3() func() { // ERROR "can inline gd3" // Issue #42788 - ensure ODEREF OCONVNOP* OADDR is low cost. func EncodeQuad(d []uint32, x [6]float32) { // ERROR "can inline EncodeQuad" "d does not escape" _ = d[:6] - d[0] = math.Float32bits(x[0]) // ERROR "inlining call to math.Float32bits" - d[1] = math.Float32bits(x[1]) // ERROR "inlining call to math.Float32bits" - d[2] = math.Float32bits(x[2]) // ERROR "inlining call to math.Float32bits" - d[3] = math.Float32bits(x[3]) // ERROR "inlining call to math.Float32bits" - d[4] = math.Float32bits(x[4]) // ERROR "inlining call to math.Float32bits" - d[5] = math.Float32bits(x[5]) // ERROR "inlining call to math.Float32bits" + d[0] = float32bits(x[0]) // ERROR "inlining call to float32bits" + d[1] = float32bits(x[1]) // ERROR "inlining call to float32bits" + d[2] = float32bits(x[2]) // ERROR "inlining call to float32bits" + d[3] = float32bits(x[3]) // ERROR "inlining call to float32bits" + d[4] = float32bits(x[4]) // ERROR "inlining call to float32bits" + d[5] = float32bits(x[5]) // ERROR "inlining call to float32bits" +} + +// float32bits is a copy of math.Float32bits to ensure that +// these tests pass with `-gcflags=-l`. +func float32bits(f float32) uint32 { // ERROR "can inline float32bits" + return *(*uint32)(unsafe.Pointer(&f)) } // Ensure OCONVNOP is zero cost.