]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: correct type of pointer difference on RISCV64
authorCherry Mui <cherryyz@google.com>
Mon, 14 Feb 2022 17:43:27 +0000 (12:43 -0500)
committerCherry Mui <cherryyz@google.com>
Mon, 14 Feb 2022 23:08:44 +0000 (23:08 +0000)
commit1ed30ca537a05b887f8479027b6363a03f957610
tree3a48ab2ebc3f4293a11d12bc1d4f202b238a7436
parentada95e2807abbbab990c5c13a271e823e4e0a5cc
cmd/compile: correct type of pointer difference on RISCV64

Pointer comparison is lowered to the following on RISCV64

(EqPtr x y) => (SEQZ (SUB <x.Type> x y))

The difference of two pointers (the SUB) should not be pointer
type. Otherwise it can cause the GC to find a bad pointer.

Should fix #51101.

Change-Id: I7e73c2155c36ff403c032981a9aa9cccbfdf0f64
Reviewed-on: https://go-review.googlesource.com/c/go/+/385655
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/compile/internal/ssa/gen/RISCV64.rules
src/cmd/compile/internal/ssa/rewriteRISCV64.go
test/fixedbugs/issue51101.go [new file with mode: 0644]