blob: e00e06a75ee9598283f50ff15f2b11cf85de032a [file] [log] [blame]
Josh Bleecher Snyder17c513e2021-09-13 15:28:55 -07001// errorcheckwithauto -0 -m -d=inlfuncswithclosures=1
2
Josh Bleecher Snyder812a33d2021-10-06 13:42:17 -07003//go:build (386 || amd64 || arm64 || ppc64le || s390x) && !gcflags_noopt
Josh Bleecher Snyder17c513e2021-09-13 15:28:55 -07004// +build 386 amd64 arm64 ppc64le s390x
Josh Bleecher Snyder812a33d2021-10-06 13:42:17 -07005// +build !gcflags_noopt
Josh Bleecher Snyder17c513e2021-09-13 15:28:55 -07006
7// Copyright 2021 The Go Authors. All rights reserved.
8// Use of this source code is governed by a BSD-style
9// license that can be found in the LICENSE file.
10
11// Similar to inline.go, but only for architectures that can merge loads.
12
13package foo
14
15import (
16 "encoding/binary"
17)
18
19// Ensure that simple encoding/binary functions are cheap enough
20// that functions using them can also be inlined (issue 42958).
21func endian(b []byte) uint64 { // ERROR "can inline endian" "b does not escape"
22 return binary.LittleEndian.Uint64(b) + binary.BigEndian.Uint64(b) // ERROR "inlining call to binary.littleEndian.Uint64" "inlining call to binary.bigEndian.Uint64"
23}