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
...@@ -408,7 +410,9 @@ func init() { ...@@ -408,7 +410,9 @@ func init() {
inputs: []regMask{buildReg("DI"), buildReg("SI")}, inputs: []regMask{buildReg("DI"), buildReg("SI")},
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)
......
...@@ -421,7 +421,8 @@ func init() { ...@@ -421,7 +421,8 @@ func init() {
inputs: []regMask{buildReg("DI"), buildReg("X0")}, inputs: []regMask{buildReg("DI"), buildReg("X0")},
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
...@@ -458,7 +460,9 @@ func init() { ...@@ -458,7 +460,9 @@ func init() {
inputs: []regMask{buildReg("DI"), buildReg("SI")}, inputs: []regMask{buildReg("DI"), buildReg("SI")},
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)
......
...@@ -568,8 +568,10 @@ func init() { ...@@ -568,8 +568,10 @@ func init() {
inputs: []regMask{buildReg("R1"), buildReg("R2"), gpsp}, inputs: []regMask{buildReg("R1"), buildReg("R2"), gpsp},
clobbers: buildReg("R1 R2"), clobbers: buildReg("R1 R2"),
}, },
clobberFlags: true, clobberFlags: true,
typ: "Mem", typ: "Mem",
faultOnNilArg0: true,
faultOnNilArg1: true,
}, },
// large clear // large clear
...@@ -592,8 +594,9 @@ func init() { ...@@ -592,8 +594,9 @@ func init() {
inputs: []regMask{buildReg("R1"), gpsp}, inputs: []regMask{buildReg("R1"), gpsp},
clobbers: buildReg("R1"), clobbers: buildReg("R1"),
}, },
clobberFlags: true, clobberFlags: true,
typ: "Mem", typ: "Mem",
faultOnNilArg0: true,
}, },
} }
......
...@@ -4071,9 +4071,10 @@ var opcodeTable = [...]opInfo{ ...@@ -4071,9 +4071,10 @@ 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
...@@ -4083,8 +4084,9 @@ var opcodeTable = [...]opInfo{ ...@@ -4083,8 +4084,9 @@ 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
...@@ -4152,10 +4154,12 @@ var opcodeTable = [...]opInfo{ ...@@ -4152,10 +4154,12 @@ var opcodeTable = [...]opInfo{
}, },
}, },
{ {
name: "DUFFCOPY", name: "DUFFCOPY",
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
...@@ -4165,8 +4169,10 @@ var opcodeTable = [...]opInfo{ ...@@ -4165,8 +4169,10 @@ 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
...@@ -7062,10 +7068,11 @@ var opcodeTable = [...]opInfo{ ...@@ -7062,10 +7068,11 @@ var opcodeTable = [...]opInfo{
}, },
}, },
{ {
name: "DUFFZERO", name: "DUFFZERO",
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
...@@ -7086,8 +7093,9 @@ var opcodeTable = [...]opInfo{ ...@@ -7086,8 +7093,9 @@ 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
...@@ -7155,10 +7163,12 @@ var opcodeTable = [...]opInfo{ ...@@ -7155,10 +7163,12 @@ var opcodeTable = [...]opInfo{
}, },
}, },
{ {
name: "DUFFCOPY", name: "DUFFCOPY",
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
...@@ -7168,8 +7178,10 @@ var opcodeTable = [...]opInfo{ ...@@ -7168,8 +7178,10 @@ 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
...@@ -19714,10 +19726,12 @@ var opcodeTable = [...]opInfo{ ...@@ -19714,10 +19726,12 @@ var opcodeTable = [...]opInfo{
}, },
}, },
{ {
name: "LoweredMove", name: "LoweredMove",
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
...@@ -19728,10 +19742,11 @@ var opcodeTable = [...]opInfo{ ...@@ -19728,10 +19742,11 @@ var opcodeTable = [...]opInfo{
}, },
}, },
{ {
name: "LoweredZero", name: "LoweredZero",
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