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: stores to unused variables on the stack not eliminated #19765

Closed
mundaym opened this issue Mar 29, 2017 · 2 comments
Closed

cmd/compile: stores to unused variables on the stack not eliminated #19765

mundaym opened this issue Mar 29, 2017 · 2 comments

Comments

@mundaym
Copy link
Member

mundaym commented Mar 29, 2017

I am trying to replace math.Float64bits and friends with register to register moves and noticed that stores to variables on the stack aren't eliminated when their all their uses have been optimized away. Is there an existing issue for this?

For example, on tip (6e9ec14):

package main

var Sink int

func main() {
	x := 1
	Sink = *(&x)
}

Compiles to:

   	00000 (/tmp/main.go:5)	TEXT	"".main(SB)
   	00001 (/tmp/main.go:5)	FUNCDATA	$0, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
   	00002 (/tmp/main.go:5)	FUNCDATA	$1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
v7	00003 (/tmp/main.go:6)	MOVQ	$1, "".x-8(SP)
v13	00004 (/tmp/main.go:7)	MOVQ	$1, "".Sink(SB)
b1	00005 (/tmp/main.go:8)	RET
   	00006 (<unknown line number>)	END

The MOVQ $1, "".x-8(SP) could be eliminated by the compiler but isn't.

@randall77
Copy link
Contributor

Kind of a dup of #13095

@gopherbot
Copy link

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

@golang golang locked and limited conversation to collaborators Aug 24, 2018
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