mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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/21861 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
cd85f711c0
commit
7f5a063d15
1 changed files with 6 additions and 1 deletions
|
|
@ -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(®, Types[Tptr], n)
|
||||
Cgen(n, ®)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue