-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
FixPendingIssues that have a fix which has not yet been reviewed or submitted.Issues that have a fix which has not yet been reviewed or submitted.arch-arm64compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
Go version
upstream
Output of go env in your module/workspace:
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/abokhanko/.cache/go-build'
GOENV='/home/abokhanko/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/abokhanko/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/abokhanko/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/abokhanko/goroot'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/abokhanko/goroot/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.23-e9ab25bdd0 Mon Feb 19 22:21:38 2024 +0300'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2057756495=/tmp/go-build -gno-record-gcc-switches'What did you do?
test.go:
package main
import "sync/atomic"
type Counter struct {
counter int32
}
func main() {
x := Counter{10}
atomic.AddInt32(&x.counter, 1)
}
Build:
GOOS=linux GOARCH=arm64 GOARM64=v8.2 go build test.go
Get disassembly:
go tool objdump -s main\.main test
What did you see happen?
Atomic add includes checks for presence of atomic instructions and a loop for ARM64 architectures that don't support them:
test.go:11 0x708cc b00007db ADRP 1019904(PC), R27
test.go:11 0x708d0 3961af61 MOVBU 2155(R27), R1
test.go:11 0x708d4 360000a1 TBZ $0, R1, 5(PC)
test.go:11 0x708d8 b24003e1 ORR $1, ZR, R1
test.go:11 0x708dc b8e10002 ?
test.go:11 0x708e0 8b010042 ADD R1, R2, R2
test.go:11 0x708e4 14000006 JMP 6(PC)
test.go:11 0x708e8 b24003e1 ORR $1, ZR, R1
test.go:11 0x708ec 885ffc02 LDAXRW (R0), R2
test.go:11 0x708f0 8b010042 ADD R1, R2, R2
test.go:11 0x708f4 881bfc02 STLXRW R2, (R0), R27
test.go:11 0x708f8 b5ffffbb CBNZ R27, -3(PC)
What did you expect to see?
With GOARCH=arm64 GOARM64=v8.2 we can eliminate runtime checks and thus, improve performance.
Metadata
Metadata
Assignees
Labels
FixPendingIssues that have a fix which has not yet been reviewed or submitted.Issues that have a fix which has not yet been reviewed or submitted.arch-arm64compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.