]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: use desired register only if it satisfies register mask
authorCherry Zhang <cherryyz@google.com>
Wed, 28 Apr 2021 15:00:15 +0000 (11:00 -0400)
committerCherry Zhang <cherryyz@google.com>
Wed, 28 Apr 2021 16:13:40 +0000 (16:13 +0000)
commit5b328c4a2fbae10ec10d233d691435fe0295fc39
treed51e0e4a88299a65dbd9087ccc5c09f0a9db709e
parentcbb3f090477de92a7e158050803ef71a5ea825ee
cmd/compile: use desired register only if it satisfies register mask

In the register allocator, if possible, we allocate a value to its
desired register (the ideal register for its next use). In some
cases the desired register does not satisfies the value's output
register mask. We should not use the register in this case.

In the following example, v33 is going to be returned as a
function result, so it is allocated to its desired register AX.
However, its Op cannot use AX as output, causing miscompilation.

v33 = CMOVQEQF <int> v24 v28 v29 : AX (~R0[int])
v35 = MakeResult <int,int,mem> v33 v26 v18
Ret v35

Change-Id: Id0f4f27c4b233ee297e83077e3c8494fe193e664
Reviewed-on: https://go-review.googlesource.com/c/go/+/314630
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/compile/internal/ssa/regalloc.go
test/abi/result_regalloc.go [new file with mode: 0644]