]> Cypherpunks repositories - gostls13.git/commit
test/codegen: fix issue with arm64 memmove codegen test
authorAlberto Donizetti <alb.donizetti@gmail.com>
Wed, 7 Mar 2018 14:06:50 +0000 (15:06 +0100)
committerAlberto Donizetti <alb.donizetti@gmail.com>
Wed, 7 Mar 2018 16:41:24 +0000 (16:41 +0000)
commitc028958393682fa559cf1555178c0caf7931a52a
tree32f7ab60c689b7807156e509fe877ac447289321
parentaa00d9744785f5215ec8e47a9bb00a4289cea3d2
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 <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
test/codegen/movesmall.go