Change-Id: I55899ff0ed2c3c01f24ab1ccf133ce4236049e39
Reviewed-on: https://go-review.googlesource.com/c/go/+/401074
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
"fmt"
"go/token"
"internal/goarch"
+ "internal/testenv"
"io"
"math"
"math/rand"
// Calling MapRange should not allocate even though it returns a *MapIter.
// The function is inlineable, so if the local usage does not escape
// the *MapIter, it can remain stack allocated.
- if got != 0 {
- t.Errorf("wanted 0 alloc, got %d", got)
+ want := 0
+ if strings.HasSuffix(testenv.Builder(), "-noopt") {
+ want = 1 // no inlining with the noopt builder
+ }
+ if got != want {
+ t.Errorf("wanted %d alloc, got %d", want, got)
}
}