mirror of
https://github.com/golang/go
synced 2024-11-18 19:54:44 -07:00
cmd/compile: convert nilcheck elim rules to typed aux
Passes toolstash-check. Change-Id: Ic7efb0e4778844366f581c6310a1a2f3bfc1868a Reviewed-on: https://go-review.googlesource.com/c/go/+/229686 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
b6f6259f2d
commit
47b5efad5d
@ -1923,31 +1923,31 @@
|
|||||||
&& mem.Op == OpStaticCall
|
&& mem.Op == OpStaticCall
|
||||||
&& isSameSym(mem.Aux, "runtime.newobject")
|
&& isSameSym(mem.Aux, "runtime.newobject")
|
||||||
&& c == config.ctxt.FixedFrameSize() + config.RegSize // offset of return value
|
&& c == config.ctxt.FixedFrameSize() + config.RegSize // offset of return value
|
||||||
-> mem
|
=> mem
|
||||||
(Store (Load (OffPtr [c] (SP)) mem) x mem)
|
(Store (Load (OffPtr [c] (SP)) mem) x mem)
|
||||||
&& isConstZero(x)
|
&& isConstZero(x)
|
||||||
&& mem.Op == OpStaticCall
|
&& mem.Op == OpStaticCall
|
||||||
&& isSameSym(mem.Aux, "runtime.newobject")
|
&& isSameSym(mem.Aux, "runtime.newobject")
|
||||||
&& c == config.ctxt.FixedFrameSize() + config.RegSize // offset of return value
|
&& c == config.ctxt.FixedFrameSize() + config.RegSize // offset of return value
|
||||||
-> mem
|
=> mem
|
||||||
(Store (OffPtr (Load (OffPtr [c] (SP)) mem)) x mem)
|
(Store (OffPtr (Load (OffPtr [c] (SP)) mem)) x mem)
|
||||||
&& isConstZero(x)
|
&& isConstZero(x)
|
||||||
&& mem.Op == OpStaticCall
|
&& mem.Op == OpStaticCall
|
||||||
&& isSameSym(mem.Aux, "runtime.newobject")
|
&& isSameSym(mem.Aux, "runtime.newobject")
|
||||||
&& c == config.ctxt.FixedFrameSize() + config.RegSize // offset of return value
|
&& c == config.ctxt.FixedFrameSize() + config.RegSize // offset of return value
|
||||||
-> mem
|
=> mem
|
||||||
// nil checks just need to rewrite to something useless.
|
// nil checks just need to rewrite to something useless.
|
||||||
// they will be deadcode eliminated soon afterwards.
|
// they will be deadcode eliminated soon afterwards.
|
||||||
(NilCheck (Load (OffPtr [c] (SP)) (StaticCall {sym} _)) _)
|
(NilCheck (Load (OffPtr [c] (SP)) (StaticCall {sym} _)) _)
|
||||||
&& isSameSym(sym, "runtime.newobject")
|
&& symNamed(sym, "runtime.newobject")
|
||||||
&& c == config.ctxt.FixedFrameSize() + config.RegSize // offset of return value
|
&& c == config.ctxt.FixedFrameSize() + config.RegSize // offset of return value
|
||||||
&& warnRule(fe.Debug_checknil(), v, "removed nil check")
|
&& warnRule(fe.Debug_checknil(), v, "removed nil check")
|
||||||
-> (Invalid)
|
=> (Invalid)
|
||||||
(NilCheck (OffPtr (Load (OffPtr [c] (SP)) (StaticCall {sym} _))) _)
|
(NilCheck (OffPtr (Load (OffPtr [c] (SP)) (StaticCall {sym} _))) _)
|
||||||
&& isSameSym(sym, "runtime.newobject")
|
&& symNamed(sym, "runtime.newobject")
|
||||||
&& c == config.ctxt.FixedFrameSize() + config.RegSize // offset of return value
|
&& c == config.ctxt.FixedFrameSize() + config.RegSize // offset of return value
|
||||||
&& warnRule(fe.Debug_checknil(), v, "removed nil check")
|
&& warnRule(fe.Debug_checknil(), v, "removed nil check")
|
||||||
-> (Invalid)
|
=> (Invalid)
|
||||||
|
|
||||||
// Evaluate constant address comparisons.
|
// Evaluate constant address comparisons.
|
||||||
(EqPtr x x) -> (ConstBool [1])
|
(EqPtr x x) -> (ConstBool [1])
|
||||||
|
@ -373,6 +373,11 @@ func canMergeLoad(target, load *Value) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// symNamed reports whether sym's name is name.
|
||||||
|
func symNamed(sym Sym, name string) bool {
|
||||||
|
return sym.String() == name
|
||||||
|
}
|
||||||
|
|
||||||
// isSameSym reports whether sym is the same as the given named symbol
|
// isSameSym reports whether sym is the same as the given named symbol
|
||||||
func isSameSym(sym interface{}, name string) bool {
|
func isSameSym(sym interface{}, name string) bool {
|
||||||
s, ok := sym.(fmt.Stringer)
|
s, ok := sym.(fmt.Stringer)
|
||||||
|
@ -16009,7 +16009,7 @@ func rewriteValuegeneric_OpNilCheck(v *Value) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// match: (NilCheck (Load (OffPtr [c] (SP)) (StaticCall {sym} _)) _)
|
// match: (NilCheck (Load (OffPtr [c] (SP)) (StaticCall {sym} _)) _)
|
||||||
// cond: isSameSym(sym, "runtime.newobject") && c == config.ctxt.FixedFrameSize() + config.RegSize && warnRule(fe.Debug_checknil(), v, "removed nil check")
|
// cond: symNamed(sym, "runtime.newobject") && c == config.ctxt.FixedFrameSize() + config.RegSize && warnRule(fe.Debug_checknil(), v, "removed nil check")
|
||||||
// result: (Invalid)
|
// result: (Invalid)
|
||||||
for {
|
for {
|
||||||
if v_0.Op != OpLoad {
|
if v_0.Op != OpLoad {
|
||||||
@ -16020,7 +16020,7 @@ func rewriteValuegeneric_OpNilCheck(v *Value) bool {
|
|||||||
if v_0_0.Op != OpOffPtr {
|
if v_0_0.Op != OpOffPtr {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
c := v_0_0.AuxInt
|
c := auxIntToInt64(v_0_0.AuxInt)
|
||||||
v_0_0_0 := v_0_0.Args[0]
|
v_0_0_0 := v_0_0.Args[0]
|
||||||
if v_0_0_0.Op != OpSP {
|
if v_0_0_0.Op != OpSP {
|
||||||
break
|
break
|
||||||
@ -16029,15 +16029,15 @@ func rewriteValuegeneric_OpNilCheck(v *Value) bool {
|
|||||||
if v_0_1.Op != OpStaticCall {
|
if v_0_1.Op != OpStaticCall {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
sym := v_0_1.Aux
|
sym := auxToSym(v_0_1.Aux)
|
||||||
if !(isSameSym(sym, "runtime.newobject") && c == config.ctxt.FixedFrameSize()+config.RegSize && warnRule(fe.Debug_checknil(), v, "removed nil check")) {
|
if !(symNamed(sym, "runtime.newobject") && c == config.ctxt.FixedFrameSize()+config.RegSize && warnRule(fe.Debug_checknil(), v, "removed nil check")) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
v.reset(OpInvalid)
|
v.reset(OpInvalid)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// match: (NilCheck (OffPtr (Load (OffPtr [c] (SP)) (StaticCall {sym} _))) _)
|
// match: (NilCheck (OffPtr (Load (OffPtr [c] (SP)) (StaticCall {sym} _))) _)
|
||||||
// cond: isSameSym(sym, "runtime.newobject") && c == config.ctxt.FixedFrameSize() + config.RegSize && warnRule(fe.Debug_checknil(), v, "removed nil check")
|
// cond: symNamed(sym, "runtime.newobject") && c == config.ctxt.FixedFrameSize() + config.RegSize && warnRule(fe.Debug_checknil(), v, "removed nil check")
|
||||||
// result: (Invalid)
|
// result: (Invalid)
|
||||||
for {
|
for {
|
||||||
if v_0.Op != OpOffPtr {
|
if v_0.Op != OpOffPtr {
|
||||||
@ -16052,7 +16052,7 @@ func rewriteValuegeneric_OpNilCheck(v *Value) bool {
|
|||||||
if v_0_0_0.Op != OpOffPtr {
|
if v_0_0_0.Op != OpOffPtr {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
c := v_0_0_0.AuxInt
|
c := auxIntToInt64(v_0_0_0.AuxInt)
|
||||||
v_0_0_0_0 := v_0_0_0.Args[0]
|
v_0_0_0_0 := v_0_0_0.Args[0]
|
||||||
if v_0_0_0_0.Op != OpSP {
|
if v_0_0_0_0.Op != OpSP {
|
||||||
break
|
break
|
||||||
@ -16061,8 +16061,8 @@ func rewriteValuegeneric_OpNilCheck(v *Value) bool {
|
|||||||
if v_0_0_1.Op != OpStaticCall {
|
if v_0_0_1.Op != OpStaticCall {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
sym := v_0_0_1.Aux
|
sym := auxToSym(v_0_0_1.Aux)
|
||||||
if !(isSameSym(sym, "runtime.newobject") && c == config.ctxt.FixedFrameSize()+config.RegSize && warnRule(fe.Debug_checknil(), v, "removed nil check")) {
|
if !(symNamed(sym, "runtime.newobject") && c == config.ctxt.FixedFrameSize()+config.RegSize && warnRule(fe.Debug_checknil(), v, "removed nil check")) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
v.reset(OpInvalid)
|
v.reset(OpInvalid)
|
||||||
@ -21606,7 +21606,7 @@ func rewriteValuegeneric_OpStore(v *Value) bool {
|
|||||||
if v_0_0.Op != OpOffPtr {
|
if v_0_0.Op != OpOffPtr {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
c := v_0_0.AuxInt
|
c := auxIntToInt64(v_0_0.AuxInt)
|
||||||
v_0_0_0 := v_0_0.Args[0]
|
v_0_0_0 := v_0_0.Args[0]
|
||||||
if v_0_0_0.Op != OpSP {
|
if v_0_0_0.Op != OpSP {
|
||||||
break
|
break
|
||||||
@ -21634,7 +21634,7 @@ func rewriteValuegeneric_OpStore(v *Value) bool {
|
|||||||
if v_0_0_0.Op != OpOffPtr {
|
if v_0_0_0.Op != OpOffPtr {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
c := v_0_0_0.AuxInt
|
c := auxIntToInt64(v_0_0_0.AuxInt)
|
||||||
v_0_0_0_0 := v_0_0_0.Args[0]
|
v_0_0_0_0 := v_0_0_0.Args[0]
|
||||||
if v_0_0_0_0.Op != OpSP {
|
if v_0_0_0_0.Op != OpSP {
|
||||||
break
|
break
|
||||||
@ -24091,7 +24091,7 @@ func rewriteValuegeneric_OpZero(v *Value) bool {
|
|||||||
if v_0_0.Op != OpOffPtr {
|
if v_0_0.Op != OpOffPtr {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
c := v_0_0.AuxInt
|
c := auxIntToInt64(v_0_0.AuxInt)
|
||||||
v_0_0_0 := v_0_0.Args[0]
|
v_0_0_0 := v_0_0.Args[0]
|
||||||
if v_0_0_0.Op != OpSP || mem != v_1 || !(mem.Op == OpStaticCall && isSameSym(mem.Aux, "runtime.newobject") && c == config.ctxt.FixedFrameSize()+config.RegSize) {
|
if v_0_0_0.Op != OpSP || mem != v_1 || !(mem.Op == OpStaticCall && isSameSym(mem.Aux, "runtime.newobject") && c == config.ctxt.FixedFrameSize()+config.RegSize) {
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user