Skip to content

cmd/compile: assembly print regression #21064

@zhangfannie

Description

@zhangfannie

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version devel +0d482b3 Mon Jul 17 18:18:08 2017 +0000 linux/arm64

What operating system and processor architecture are you using (go env)?

fanzha02@fanzha02-01-arm-vm:~/golangtmp$ ./bin/go env
GOARCH="arm64"
GOBIN=""
GOEXE=""
GOHOSTARCH="arm64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/fanzha02/go"
GORACE=""
GOROOT="/home/fanzha02/golangtmp"
GOTOOLDIR="/home/fanzha02/golangtmp/pkg/tool/linux_arm64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build506052363=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

  1. create a new go program and save as test.go file.
    package main func g(x *int) { *x = *x+2 } func f(x int) { g(&x) } func main(){ f(2) }
  2. $ /home/fanzha02/golangtmp/bin/go tool compile -S -l test.go > test,s
  3. please refer to the below assembly code.
    0x0000 00000 (test1.go:16) TEXT "".f(SB), $88-8
    0x0000 00000 (test1.go:16) MOVD 16(g), R1
    0x0004 00004 (test1.go:16) MOVD RSP, R2
    0x0008 00008 (test1.go:16) CMP R1, R2
    0x000c 00012 (test1.go:16) BLS 140
    0x0010 00016 (test1.go:16) MOVD.W R30, -96(RSP)
    0x0014 00020 (test1.go:16) FUNCDATA ZR, gclocals·263043c8f03e3241528dfae4e2812ef4(SB)
    0x0014 00020 (test1.go:16) FUNCDATA $1, gclocals·e226d4ae4a7cad8835311c6a4683c14f(SB)
    0x0014 00020 (test1.go:16) MOVD $"".x(FP), R0
    0x0018 00024 (test1.go:17) MOVD R0, 8(RSP)
    0x001c 00028 (test1.go:17) PCDATA ZR, ZR
    0x001c 00028 (test1.go:17) CALL "".g(SB)
    0x0020 00032 (test1.go:18) MOVD "".x(RSP), R0
    `
  4. when assembler assembles instruction "MOVD x(RSP), R0" and gives the error information "expected pseudo-register; found RSP".

I'd argue that two instructions "MOVD "".x(RSP), R0" and "MOVD $"".x(FP), R0" are misleading. In addition, the expression of "".x(RSP) and 8(RSP) are confusing . For go1.6, the paramenter's base register is printed as FP.

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

What did you expect to see?

What did you see instead?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions