-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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/compile: invalid instruction: MOVL $11553462026240, AX #41711
Comments
cc @randall77 |
I'm trying to reproduce, this has the look and feel of a bug I thought I could create on MIPS, that I (also) encountered with late call expansion. Basically, if you can smuggle a funny constant past the early phases and have it appear "late" (e.g., within late call expansion, which is not in this compiler yet, or in prove, which is), surprising things can happen. I solved it for MIPS by adding some code generation rules, but I don't see the same missing rules on AMD64 so it is not an exact duplicate. |
No, it's weirder than that. Compare compilation of the two
I've got other things to work on, just wanted to be sure that wasn't a variant of the bug I fixed just the other day for MIPS. |
FWIW, a slightly more contained repro - no imports and simplied where possible: |
This looks to me like a rule isn't sign extending an int32 constant to 64 bits. The pretty printer will just ignore the high bits but the MOVL will get a copy of the raw int64 value. I bet the new typed rules in master will fix it. I got curious and took a quick look at the AMD64 rules in Go 1.15. This looks like the sort of rule that could cause an issue like this: go/src/cmd/compile/internal/ssa/gen/AMD64.rules Line 1457 in fa01c8a
(The sign extension to 64-bits happens before the shift and not after, so the resulting value could be out-of-range for an int32. This particular rule probably doesn't trigger very often because the generic rules do most constant folding.) |
A |
Yep (based on #41711 (comment)).
|
@gopherbot please open a backport issue for 1.15. |
Seems to be ok for 1.14 and earlier. |
Backport issue(s) opened: #41720 (for 1.15). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
Also ok at tip. Just 1.15 needs fixing. |
Change https://golang.org/cl/258817 mentions this issue: |
…rule The 32-bit left shift constant folding rule should keep its result properly sign extended. Fixes #41720 Fixes #41711 Change-Id: I0fc74444d444274e911952e1725dab0b7737a846 Reviewed-on: https://go-review.googlesource.com/c/go/+/258817 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org>
@randall77 , is it okay to close this issue now that the 1.15 CL is in? |
Yes. |
…rule The 32-bit left shift constant folding rule should keep its result properly sign extended. Fixes golang#41720 Fixes golang#41711 Change-Id: I0fc74444d444274e911952e1725dab0b7737a846 Reviewed-on: https://go-review.googlesource.com/c/go/+/258817 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org>
Filed on behalf of Jan Mercl (from a golang-dev thread).
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
)?What did you do?
What did you expect to see?
Nothing but a command prompt.
What did you see instead?
The text was updated successfully, but these errors were encountered: