]> Cypherpunks repositories - gostls13.git/commitdiff
test: fix inline.go test for linux-amd64-noopt
authorEgon Elbre <egonelbre@gmail.com>
Wed, 24 Feb 2021 19:08:52 +0000 (21:08 +0200)
committerBryan C. Mills <bcmills@google.com>
Thu, 25 Feb 2021 02:22:12 +0000 (02:22 +0000)
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 <josharian@gmail.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

test/inline.go

index 44c746b2823010b00f11719b0c07d6b58cb36bbf..bc23768d0161a87bd4f4ab398edda3c71362179b 100644 (file)
@@ -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.