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: regression passing constants to mapaccess routines #19015

Closed
randall77 opened this issue Feb 9, 2017 · 4 comments
Closed

cmd/compile: regression passing constants to mapaccess routines #19015

randall77 opened this issue Feb 9, 2017 · 4 comments

Comments

@randall77
Copy link
Contributor

func f(m map[int]int) int {
	return m[5]
}

Passing the 5 to mapaccess1_fast64 used to be just a store of 5 to the stack. Now it is a load of 5 from a global constant, then a store of that value to the stack.

In Go 1.8rc3:

	0x001d 00029 (tmp2.go:4)	LEAQ	type.map[int]int(SB), AX
	0x0024 00036 (tmp2.go:4)	MOVQ	AX, (SP)
	0x0028 00040 (tmp2.go:4)	MOVQ	"".m+48(FP), AX
	0x002d 00045 (tmp2.go:4)	MOVQ	AX, 8(SP)
	0x0032 00050 (tmp2.go:4)	MOVQ	$5, 16(SP)
	0x003b 00059 (tmp2.go:4)	PCDATA	$0, $1
	0x003b 00059 (tmp2.go:4)	CALL	runtime.mapaccess1_fast64(SB)

At tip:

	0x001d 00029 (tmp2.go:4)	LEAQ	type.map[int]int(SB), AX
	0x0024 00036 (tmp2.go:4)	MOVQ	AX, (SP)
	0x0028 00040 (tmp2.go:4)	MOVQ	"".m+48(FP), AX
	0x002d 00045 (tmp2.go:4)	MOVQ	AX, 8(SP)
	0x0032 00050 (tmp2.go:4)	MOVQ	"".statictmp_0(SB), AX
	0x0039 00057 (tmp2.go:4)	MOVQ	AX, 16(SP)
	0x003e 00062 (tmp2.go:4)	PCDATA	$0, $1
	0x003e 00062 (tmp2.go:4)	CALL	runtime.mapaccess1_fast64(SB)

@mdempsky
Might be related to #18370.

This issue doesn't seem to occur for regular function calls - we marshal those arguments correctly.

@bradfitz
Copy link
Contributor

bradfitz commented Feb 9, 2017

Or @josharian's 0358367 or c682d32?

@bradfitz bradfitz added this to the Go1.9 milestone Feb 9, 2017
@cherrymui
Copy link
Member

It is c682d32, CL https://go-review.googlesource.com/35554. Before this CL, it generates autotmp to make the constant addressable, after this CL it makes statictmp. It seems that we actually don't need to make it addressable though?

@josharian
Copy link
Contributor

Looking into this

@gopherbot
Copy link

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

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

5 participants