-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
cmd/asm: incorrectly signaled 'R15 as clobbered' in MULXQ #58632
Comments
This is a tricky one, as there's no solid indication at the assembly level that a register is output only. Lots of instructions in x86 update the output register (e.g. For instructions we know are pure overwriters, we could add additional cases to the end of An easy workaround is to just add a |
Based on the Intel docs [1] [2]: Is it possible to add this exception for MULX in the meantime a sophisticated abstraction for all instructions is implemented? Note that [1] https://www.intel.com/content/dam/www/public/us/en/documents/white-papers/ia-large-integer-arithmetic-paper.pdf |
It is possible, sure. I'd just rather fix it once and for all instead of doing one-off instruction patches repeatedly. Some other instructions that have the same problem/feature:
The workaround doesn't need to replace |
The overhead is not so big considering the CPU issues only micro-instructions for In my use case, by applying this workaround, the patches to the current assembler code were reduced. This indicates that the original code is correct, but the compiler emits a false positive. So I left this ticket open until the systematic solution for all instructions is completed. Workaround TEXT ·a2(SB),0,$0-0
CMPL ·myGlobal(SB), $0
+ MOVL $0, R15
MULXQ AX, R15, DX
RET
TEXT ·a3(SB),0,$0-0
CMPL ·myGlobal(SB), $0
+ MOVL $0, R15
MULXQ AX, DX, R15
RET |
Change https://go.dev/cl/476295 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
main.go
mulx_amd64.s
Command:
What did you expect to see?
Compiler triggers 1 error. This is a true error, since R15 is being used as an input of MULX.
What did you see instead?
The compiler signals 3 errors. The first one is a true error. The second and third are false positives, since R15 is being used as an output of MULX.
To confirm this, note that the
a4
function has no error as R15 is used as output of MOVQ.Other info:
The closest CL related to this issue is: https://go-review.googlesource.com/c/go/+/283474
I found this issue while working in cloudflare/circl#407
The text was updated successfully, but these errors were encountered: