Skip to content
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 instructions #14862

Closed
brtzsnr opened this issue Mar 18, 2016 · 2 comments
Closed

cmd/compile: invalid instructions #14862

brtzsnr opened this issue Mar 18, 2016 · 2 comments

Comments

@brtzsnr
Copy link
Contributor

brtzsnr commented Mar 18, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    tip + patch https://go-review.googlesource.com/#/c/20833/3
  2. What operating system and processor architecture are you using (go env)?
    linux + amd64
  3. What did you do?
    Compile
package main

var si []int = make([]int, 10)

var X interface{}

func use(y interface{}) {
        X = y
}

func main() {
        const ci64big int64 = 1 << 31
        use(si[ci64big])
}
  1. What did you expect to see?
    To compile.
  2. What did you see instead?
    ./foo.go:15: invalid instruction: 00054 (/tmp/foo.go:13) ADDQ $17179869184, CX
  3. Additional information
    The manual http://support.amd.com/TechDocs/24594.pdf page 79 says that ADDQ imm only works with AX, but here CX is generated.

I believe the bug is here:
{name: "ADDQconst", argLength: 1, reg: gp11, asm: "ADDQ", aux: "Int64", resultInArg0: true, typ: "UInt64"}, // arg0 + auxint
or in the actual encoding of the instruction. We should probably fallback to LEAQ if the output goes to a different register.

@randall77

@randall77
Copy link
Contributor

You can add to registers other than AX, I think you're misreading that manual (it is just that the add to AX and the add to other registers is encoded differently). The problem is that you can't add a 64-bit immediate. Immediates are required to fit in sign-extended 32 bits. We need to fix this generally in our OP -> OPconst rewrite rules. I'll hack up a fix.

@gopherbot
Copy link

CL https://golang.org/cl/20815 mentions this issue.

@golang golang locked and limited conversation to collaborators Mar 20, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants