Commit fddc0045 authored by Cherry Zhang's avatar Cherry Zhang

cmd/compile: remove nil check for Zero/Move on 386, AMD64, S390X

Fixes #18003.

Change-Id: Iadcc5c424c64badecfb5fdbd4dbd9197df56182c
Reviewed-on: https://go-review.googlesource.com/33421
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarKeith Randall <khr@golang.org>
parent c1363b2d
...@@ -373,6 +373,7 @@ func init() { ...@@ -373,6 +373,7 @@ func init() {
clobbers: buildReg("DI CX"), clobbers: buildReg("DI CX"),
// Note: CX is only clobbered when dynamic linking. // Note: CX is only clobbered when dynamic linking.
}, },
faultOnNilArg0: true,
}, },
// arg0 = address of memory to zero // arg0 = address of memory to zero
...@@ -387,6 +388,7 @@ func init() { ...@@ -387,6 +388,7 @@ func init() {
inputs: []regMask{buildReg("DI"), buildReg("CX"), buildReg("AX")}, inputs: []regMask{buildReg("DI"), buildReg("CX"), buildReg("AX")},
clobbers: buildReg("DI CX"), clobbers: buildReg("DI CX"),
}, },
faultOnNilArg0: true,
}, },
{name: "CALLstatic", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "SymOff", clobberFlags: true, call: true}, // call static function aux.(*gc.Sym). arg0=mem, auxint=argsize, returns mem {name: "CALLstatic", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "SymOff", clobberFlags: true, call: true}, // call static function aux.(*gc.Sym). arg0=mem, auxint=argsize, returns mem
...@@ -409,6 +411,8 @@ func init() { ...@@ -409,6 +411,8 @@ func init() {
clobbers: buildReg("DI SI CX"), // uses CX as a temporary clobbers: buildReg("DI SI CX"), // uses CX as a temporary
}, },
clobberFlags: true, clobberFlags: true,
faultOnNilArg0: true,
faultOnNilArg1: true,
}, },
// arg0 = destination pointer // arg0 = destination pointer
...@@ -423,6 +427,8 @@ func init() { ...@@ -423,6 +427,8 @@ func init() {
inputs: []regMask{buildReg("DI"), buildReg("SI"), buildReg("CX")}, inputs: []regMask{buildReg("DI"), buildReg("SI"), buildReg("CX")},
clobbers: buildReg("DI SI CX"), clobbers: buildReg("DI SI CX"),
}, },
faultOnNilArg0: true,
faultOnNilArg1: true,
}, },
// (InvertFlags (CMPL a b)) == (CMPL b a) // (InvertFlags (CMPL a b)) == (CMPL b a)
......
...@@ -422,6 +422,7 @@ func init() { ...@@ -422,6 +422,7 @@ func init() {
clobbers: buildReg("DI"), clobbers: buildReg("DI"),
}, },
clobberFlags: true, clobberFlags: true,
faultOnNilArg0: true,
}, },
{name: "MOVOconst", reg: regInfo{nil, 0, []regMask{fp}}, typ: "Int128", aux: "Int128", rematerializeable: true}, {name: "MOVOconst", reg: regInfo{nil, 0, []regMask{fp}}, typ: "Int128", aux: "Int128", rematerializeable: true},
...@@ -437,6 +438,7 @@ func init() { ...@@ -437,6 +438,7 @@ func init() {
inputs: []regMask{buildReg("DI"), buildReg("CX"), buildReg("AX")}, inputs: []regMask{buildReg("DI"), buildReg("CX"), buildReg("AX")},
clobbers: buildReg("DI CX"), clobbers: buildReg("DI CX"),
}, },
faultOnNilArg0: true,
}, },
{name: "CALLstatic", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "SymOff", clobberFlags: true, call: true}, // call static function aux.(*gc.Sym). arg0=mem, auxint=argsize, returns mem {name: "CALLstatic", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "SymOff", clobberFlags: true, call: true}, // call static function aux.(*gc.Sym). arg0=mem, auxint=argsize, returns mem
...@@ -459,6 +461,8 @@ func init() { ...@@ -459,6 +461,8 @@ func init() {
clobbers: buildReg("DI SI X0"), // uses X0 as a temporary clobbers: buildReg("DI SI X0"), // uses X0 as a temporary
}, },
clobberFlags: true, clobberFlags: true,
faultOnNilArg0: true,
faultOnNilArg1: true,
}, },
// arg0 = destination pointer // arg0 = destination pointer
...@@ -473,6 +477,8 @@ func init() { ...@@ -473,6 +477,8 @@ func init() {
inputs: []regMask{buildReg("DI"), buildReg("SI"), buildReg("CX")}, inputs: []regMask{buildReg("DI"), buildReg("SI"), buildReg("CX")},
clobbers: buildReg("DI SI CX"), clobbers: buildReg("DI SI CX"),
}, },
faultOnNilArg0: true,
faultOnNilArg1: true,
}, },
// (InvertFlags (CMPQ a b)) == (CMPQ b a) // (InvertFlags (CMPQ a b)) == (CMPQ b a)
......
...@@ -570,6 +570,8 @@ func init() { ...@@ -570,6 +570,8 @@ func init() {
}, },
clobberFlags: true, clobberFlags: true,
typ: "Mem", typ: "Mem",
faultOnNilArg0: true,
faultOnNilArg1: true,
}, },
// large clear // large clear
...@@ -594,6 +596,7 @@ func init() { ...@@ -594,6 +596,7 @@ func init() {
}, },
clobberFlags: true, clobberFlags: true,
typ: "Mem", typ: "Mem",
faultOnNilArg0: true,
}, },
} }
......
...@@ -4074,6 +4074,7 @@ var opcodeTable = [...]opInfo{ ...@@ -4074,6 +4074,7 @@ var opcodeTable = [...]opInfo{
name: "DUFFZERO", name: "DUFFZERO",
auxType: auxInt64, auxType: auxInt64,
argLen: 3, argLen: 3,
faultOnNilArg0: true,
reg: regInfo{ reg: regInfo{
inputs: []inputInfo{ inputs: []inputInfo{
{0, 128}, // DI {0, 128}, // DI
...@@ -4085,6 +4086,7 @@ var opcodeTable = [...]opInfo{ ...@@ -4085,6 +4086,7 @@ var opcodeTable = [...]opInfo{
{ {
name: "REPSTOSL", name: "REPSTOSL",
argLen: 4, argLen: 4,
faultOnNilArg0: true,
reg: regInfo{ reg: regInfo{
inputs: []inputInfo{ inputs: []inputInfo{
{0, 128}, // DI {0, 128}, // DI
...@@ -4156,6 +4158,8 @@ var opcodeTable = [...]opInfo{ ...@@ -4156,6 +4158,8 @@ var opcodeTable = [...]opInfo{
auxType: auxInt64, auxType: auxInt64,
argLen: 3, argLen: 3,
clobberFlags: true, clobberFlags: true,
faultOnNilArg0: true,
faultOnNilArg1: true,
reg: regInfo{ reg: regInfo{
inputs: []inputInfo{ inputs: []inputInfo{
{0, 128}, // DI {0, 128}, // DI
...@@ -4167,6 +4171,8 @@ var opcodeTable = [...]opInfo{ ...@@ -4167,6 +4171,8 @@ var opcodeTable = [...]opInfo{
{ {
name: "REPMOVSL", name: "REPMOVSL",
argLen: 4, argLen: 4,
faultOnNilArg0: true,
faultOnNilArg1: true,
reg: regInfo{ reg: regInfo{
inputs: []inputInfo{ inputs: []inputInfo{
{0, 128}, // DI {0, 128}, // DI
...@@ -7066,6 +7072,7 @@ var opcodeTable = [...]opInfo{ ...@@ -7066,6 +7072,7 @@ var opcodeTable = [...]opInfo{
auxType: auxInt64, auxType: auxInt64,
argLen: 3, argLen: 3,
clobberFlags: true, clobberFlags: true,
faultOnNilArg0: true,
reg: regInfo{ reg: regInfo{
inputs: []inputInfo{ inputs: []inputInfo{
{0, 128}, // DI {0, 128}, // DI
...@@ -7088,6 +7095,7 @@ var opcodeTable = [...]opInfo{ ...@@ -7088,6 +7095,7 @@ var opcodeTable = [...]opInfo{
{ {
name: "REPSTOSQ", name: "REPSTOSQ",
argLen: 4, argLen: 4,
faultOnNilArg0: true,
reg: regInfo{ reg: regInfo{
inputs: []inputInfo{ inputs: []inputInfo{
{0, 128}, // DI {0, 128}, // DI
...@@ -7159,6 +7167,8 @@ var opcodeTable = [...]opInfo{ ...@@ -7159,6 +7167,8 @@ var opcodeTable = [...]opInfo{
auxType: auxInt64, auxType: auxInt64,
argLen: 3, argLen: 3,
clobberFlags: true, clobberFlags: true,
faultOnNilArg0: true,
faultOnNilArg1: true,
reg: regInfo{ reg: regInfo{
inputs: []inputInfo{ inputs: []inputInfo{
{0, 128}, // DI {0, 128}, // DI
...@@ -7170,6 +7180,8 @@ var opcodeTable = [...]opInfo{ ...@@ -7170,6 +7180,8 @@ var opcodeTable = [...]opInfo{
{ {
name: "REPMOVSQ", name: "REPMOVSQ",
argLen: 4, argLen: 4,
faultOnNilArg0: true,
faultOnNilArg1: true,
reg: regInfo{ reg: regInfo{
inputs: []inputInfo{ inputs: []inputInfo{
{0, 128}, // DI {0, 128}, // DI
...@@ -19718,6 +19730,8 @@ var opcodeTable = [...]opInfo{ ...@@ -19718,6 +19730,8 @@ var opcodeTable = [...]opInfo{
auxType: auxInt64, auxType: auxInt64,
argLen: 4, argLen: 4,
clobberFlags: true, clobberFlags: true,
faultOnNilArg0: true,
faultOnNilArg1: true,
reg: regInfo{ reg: regInfo{
inputs: []inputInfo{ inputs: []inputInfo{
{0, 2}, // R1 {0, 2}, // R1
...@@ -19732,6 +19746,7 @@ var opcodeTable = [...]opInfo{ ...@@ -19732,6 +19746,7 @@ var opcodeTable = [...]opInfo{
auxType: auxInt64, auxType: auxInt64,
argLen: 3, argLen: 3,
clobberFlags: true, clobberFlags: true,
faultOnNilArg0: true,
reg: regInfo{ reg: regInfo{
inputs: []inputInfo{ inputs: []inputInfo{
{0, 2}, // R1 {0, 2}, // R1
......
...@@ -254,3 +254,8 @@ func f7() (*Struct, float64) { ...@@ -254,3 +254,8 @@ func f7() (*Struct, float64) {
p := &t.Y // ERROR "removed nil check" p := &t.Y // ERROR "removed nil check"
return t, *p // ERROR "removed nil check" return t, *p // ERROR "removed nil check"
} }
// make sure to remove nil check for memory move (issue #18003)
func f8(t *[8]int) [8]int {
return *t // ERROR "removed nil check"
}
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