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: GOARM=5 bad floating point #15440

Closed
randall77 opened this issue Apr 25, 2016 · 3 comments
Closed

cmd/compile: GOARM=5 bad floating point #15440

randall77 opened this issue Apr 25, 2016 · 3 comments
Milestone

Comments

@randall77
Copy link
Contributor

Looks like the floating-point simulator for arm5 can't handle floating point writes at large offsets to pointers.

func TestArmFloatBigOffset(t *testing.T) {
    type X struct {
        pad [1024]byte
        v   float64
    }
    f := func(x *X, v float64) {
        x.v = v
    }
    var x X
    f(&x, 2.0)
    if v := x.v; v != 2.0 {
        t.Errorf("bad x.v=%f\n", v)
    }
}

The Go compiler compiles the write in f to:

    0x0014 00020 (tmp2.go:9)    CALL    _sfloat(SB)
    0x0018 00024 (tmp2.go:9)    MOVD    "".v+4(FP), F0
    0x001c 00028 (tmp2.go:9)    MOVD    F0, 1024(R0)

which all looks ok, until you see what the obj library did to it:

   11014:       eb017942        bl      6f524 <_sfloat>
   11018:       ed9d0b03        vldr    d0, [sp, #12]
   1101c:       e59fb018        ldr     fp, [pc, #24]   ; 1103c <main.f+0x3c>
   11020:       e08bb000        add     fp, fp, r0
   11024:       ed8b0b00        vstr    d0, [fp]
   ...
   1103c:       00000400        andeq   r0, r0, r0, lsl #8

The problem (I think) is the sfloat interpreter stops interpreting when it gets to the ldr, and the store doesn't work due to there not being a sfloat call before it.

This issue is what is currently breaking the linux-arm-arm5 build.

@minux

@randall77 randall77 added this to the Go1.7 milestone Apr 25, 2016
@mwhudson
Copy link
Contributor

I actually think it's

   11020:       e08bb000        add     fp, fp, r0

that's not being interpreted. Should be easy enough though.

@randall77
Copy link
Contributor Author

Yes, looks pretty easy. Fix for review: https://go-review.googlesource.com/22440

@randall77 randall77 self-assigned this Apr 25, 2016
@gopherbot
Copy link

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

@golang golang locked and limited conversation to collaborators Apr 25, 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