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: storing strings doesn't take advantage of paired stores on arm64 #72741

Open
randall77 opened this issue Mar 7, 2025 · 0 comments
Labels
BugReport Issues describing a possible bug in the Go implementation. compiler/runtime Issues related to the Go compiler and/or runtime. Performance
Milestone

Comments

@randall77
Copy link
Contributor

func f(p *string, s string) {
	*p = s
}

Compiles to:

	0x001c 00028 	MOVD	R2, 8(R0) // write length
	0x0020 00032 	MOVWU	runtime.writeBarrier(SB), R2
	0x0028 00040 	CBZW	R2, 56
	0x002c 00044 	MOVD	(R0), R2 // load old pointer
	0x0030 00048 	CALL	runtime.gcWriteBarrier2(SB)
	0x0034 00052 	STP	(R1, R2), (R25) // write new ptr & old ptr to write barrier buffer
	0x0038 00056 	MOVD	R1, (R0) // write new ptr

It would be nice if we wrote the length and ptr together at the end (effectively merging the first and last instructions).

The length and ptr writes get separated because the write barrier pass picks the smallest set of writes to include in the barrier. Which in this case, is just the one pointer write. Maybe we could include one more non-ptr write in the barrier group if we know it could be merged with a pointer write.

@randall77 randall77 added this to the Unplanned milestone Mar 7, 2025
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Mar 7, 2025
@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation. compiler/runtime Issues related to the Go compiler and/or runtime. Performance
Projects
None yet
Development

No branches or pull requests

3 participants