From 6adaf17eaaa7f2a8ec59a01f5b7280db210b3e75 Mon Sep 17 00:00:00 2001 From: David Chase Date: Wed, 9 Oct 2019 18:06:06 -0400 Subject: cmd/compile: preserve statements in late nilcheckelim optimization When a subsequent load/store of a ptr makes the nil check of that pointer unnecessary, if their lines differ, change the line of the load/store to that of the nilcheck, and attempt to rehome the load/store position instead. This fix makes profiling less accurate in order to make panics more informative. Fixes #33724 Change-Id: Ib9afaac12fe0d0320aea1bf493617facc34034b3 Reviewed-on: https://go-review.googlesource.com/c/go/+/200197 Run-TryBot: David Chase TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- test/codegen/memcombine.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/codegen') diff --git a/test/codegen/memcombine.go b/test/codegen/memcombine.go index d5f3af7692..e2d703cb0c 100644 --- a/test/codegen/memcombine.go +++ b/test/codegen/memcombine.go @@ -321,8 +321,8 @@ func fcall_uint32(a, b uint32) (uint32, uint32) { // We want to merge load+op in the first function, but not in the // second. See Issue 19595. func load_op_merge(p, q *int) { - x := *p - *q += x // amd64:`ADDQ\t\(` + x := *p // amd64:`ADDQ\t\(` + *q += x // The combined nilcheck and load would normally have this line number, but we want that combined operation to have the line number of the nil check instead (see #33724). } func load_op_no_merge(p, q *int) { x := *p -- cgit v1.3-5-g9baa