Commit 7f5a063d authored by Michael Munday's avatar Michael Munday Committed by Brad Fitzpatrick

cmd/compile/internal/gc: minor Cgen_checknil cleanup

Most architectures can only generate nil checks when the
the address to check is in a register. Currently only
amd64 and 386 can generate checks for addresses that
reside in memory. This is unlikely to change so the architecture
check has been inverted.

Change-Id: I73697488a183406c79a9039c62823712b510bb6a
Reviewed-on: https://go-review.googlesource.com/21861Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent cd85f711
......@@ -324,7 +324,12 @@ func Cgen_checknil(n *Node) {
Fatalf("bad checknil")
}
if (Thearch.LinkArch.InFamily(sys.MIPS64, sys.ARM, sys.ARM64, sys.PPC64) && n.Op != OREGISTER) || !n.Addable || n.Op == OLITERAL {
// Most architectures require that the address to be checked is
// in a register (it could be in memory).
needsReg := !Thearch.LinkArch.InFamily(sys.AMD64, sys.I386)
// Move the address to be checked into a register if necessary.
if (needsReg && n.Op != OREGISTER) || !n.Addable || n.Op == OLITERAL {
var reg Node
Regalloc(&reg, Types[Tptr], n)
Cgen(n, &reg)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment