-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/internal/obj: rewriting MOVQ to XOR causes bugs and confusion #20986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Have you tried on tip or 1.9beta2? |
I don't think there's anything to say beyond what was said in #12405. Unless Russ has changed his mind, this is a documentation issue. |
I just chatted about this with several runtime/compiler people and we all agreed that this should be removed from obj (and done explicitly in the compiler where it makes sense). Now someone just has to do it. :) |
Change https://golang.org/cl/73072 mentions this issue: |
Change https://golang.org/cl/73073 mentions this issue: |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.8.3 linux/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/hdevalence/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build126311645=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
What did you do?
I put
MOVQ $0, AX
in a Go assembly file.What did you expect to see?
A move instruction, such as
or any other equivalent instruction.
What did you see instead?
An XOR, which clobbers the carry flags, breaking the program.
This is essentially a duplicate of #12405, which is now locked. That issue notes that MOV is now "marked as clobbering flags" (presumably in the compiler internals?) but this fact seems not to be documented in either the Go assembly documentation or in the Plan 9 assembler documentation.
The text was updated successfully, but these errors were encountered: