aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/testdata
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2025-09-22 10:57:29 -0400
committerCherry Mui <cherryyz@google.com>2025-10-03 12:31:20 -0700
commit38b26f29f1f97d24afc852b9f4eee829341ee682 (patch)
tree0b0d35385870fb46f10629b16270aff76bdc6a79 /src/runtime/testdata
parent003b5ce1bc15cf265e74ba1ec4eb7cf801e49986 (diff)
downloadgo-38b26f29f1f97d24afc852b9f4eee829341ee682.tar.xz
cmd/compile: remove stores to unread parameters
Currently, we remove stores to local variables that are not read. We don't do that for arguments. But arguments and locals are essentially the same. Arguments are passed by value, and are not expected to be read in the caller's frame. So we can remove the writes to them as well. One exception is the cgo_unsafe_arg directive, which makes all the arguments effectively address-taken. cgo_unsafe_arg implies ABI0, so we just skip ABI0 functions' arguments. Cherry-picked from the dev.simd branch. This CL is not necessarily SIMD specific. Apply early to reduce risk. Change-Id: I8999fc50da6a87f22c1ec23e9a0c15483b6f7df8 Reviewed-on: https://go-review.googlesource.com/c/go/+/705815 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/708865
Diffstat (limited to 'src/runtime/testdata')
-rw-r--r--src/runtime/testdata/testprog/badtraceback.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/runtime/testdata/testprog/badtraceback.go b/src/runtime/testdata/testprog/badtraceback.go
index 09aa2b877e..455118a543 100644
--- a/src/runtime/testdata/testprog/badtraceback.go
+++ b/src/runtime/testdata/testprog/badtraceback.go
@@ -44,6 +44,8 @@ func badLR2(arg int) {
lrPtr := (*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&arg)) - lrOff))
*lrPtr = 0xbad
+ runtime.KeepAlive(lrPtr) // prevent dead store elimination
+
// Print a backtrace. This should include diagnostics for the
// bad return PC and a hex dump.
panic("backtrace")