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: regalloc restoring to dead register #14761

Closed
randall77 opened this issue Mar 11, 2016 · 1 comment
Closed

cmd/compile: regalloc restoring to dead register #14761

randall77 opened this issue Mar 11, 2016 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. Performance
Milestone

Comments

@randall77
Copy link
Contributor

func f(p *int, v int, b bool) int {
    if b {
        *p = v
    }
    runtime.GC()
    return *p
}

This compiles to:

    0x000f 00015 (/home/khr/go/tmp2.go:5)   MOVBLZX "".b+24(FP), AX
    0x0014 00020 (/home/khr/go/tmp2.go:5)   TESTB   AL, AL
    0x0016 00022 (/home/khr/go/tmp2.go:6)   JEQ 56
    0x0018 00024 (/home/khr/go/tmp2.go:7)   MOVQ    "".p+8(FP), CX
    0x001d 00029 (/home/khr/go/tmp2.go:7)   MOVQ    "".v+16(FP), DX
    0x0022 00034 (/home/khr/go/tmp2.go:7)   MOVQ    DX, (CX)
    0x0025 00037 (/home/khr/go/tmp2.go:9)   PCDATA  $0, $0
    0x0025 00037 (/home/khr/go/tmp2.go:9)   CALL    runtime.GC(SB)
        ...
    0x0038 00056 (/home/khr/go/tmp2.go:5)   MOVQ    "".p+8(FP), CX
    0x003d 00061 (/home/khr/go/tmp2.go:9)   JMP 37

Notice the restore of p at 56 which is unnecessary, as CX is dead. This is just the register allocator trying to get the same data in the same registers as the other predecessor of instruction 37. We currently match only the values in registers which are live. But we really should match values in registers which are live and which are used at least once.

@bradfitz bradfitz added this to the Go1.7 milestone Apr 10, 2016
@randall77 randall77 modified the milestones: Go1.8, Go1.7 Apr 29, 2016
@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 11, 2016
@rsc rsc modified the milestones: Go1.9, Go1.8 Oct 21, 2016
@gopherbot
Copy link
Contributor

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

@golang golang locked and limited conversation to collaborators Mar 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. Performance
Projects
None yet
Development

No branches or pull requests

5 participants