From c028958393682fa559cf1555178c0caf7931a52a Mon Sep 17 00:00:00 2001 From: Alberto Donizetti Date: Wed, 7 Mar 2018 15:06:50 +0100 Subject: [PATCH] test/codegen: fix issue with arm64 memmove codegen test This recently added arm64 memmove codegen check: func movesmall() { // arm64:-"memmove" x := [...]byte{1, 2, 3, 4, 5, 6, 7} copy(x[1:], x[:]) } is not correct, for two reasons: 1. regexps are matched from the start of the disasm line (excluding line information). This mean that a negative -"memmove" check will pass against a 'CALL runtime.memmove' line because the line does not start with 'memmove' (its starts with CALL...). The way to specify no 'memmove' match whatsoever on the line is -".*memmove" 2. AFAIK comments on their own line are matched against the first subsequent non-comment line. So the code above only verifies that the x := ... line does not generate a memmove. The comment should be moved near the copy() line, if it's that one we want to not generate a memmove call. The fact that the test above is not effective can be checked by running `go run run.go -v codegen` in the toplevel test directory with a go1.10 toolchain (that does not have the memmove-elision optimization). The test will still pass (it shouldn't). This change changes the regexp to -".*memmove" and moves it near the line it needs to (not)match. Change-Id: Ie01ef4d775e77d92dc8d8b7856b89b200f5e5ef2 Reviewed-on: https://go-review.googlesource.com/98977 Run-TryBot: Alberto Donizetti TryBot-Result: Gobot Gobot Reviewed-by: Cherry Zhang --- test/codegen/movesmall.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/codegen/movesmall.go b/test/codegen/movesmall.go index 59b2a16dd1..9ad83a5b9e 100644 --- a/test/codegen/movesmall.go +++ b/test/codegen/movesmall.go @@ -7,7 +7,6 @@ package codegen func movesmall() { - // arm64:-"memmove" x := [...]byte{1, 2, 3, 4, 5, 6, 7} - copy(x[1:], x[:]) + copy(x[1:], x[:]) // arm64:-".*memmove" } -- 2.48.1