mirror of
https://github.com/golang/go
synced 2024-11-24 00:20:14 -07:00
cmd/compile: move v.Pos.line check to warnRule
This simplifies the rewrite rules. Change-Id: Iff062297d42a23cb31ad55e8c733842ecbc07da2 Reviewed-on: https://go-review.googlesource.com/129377 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
43f54c8d2e
commit
25b84c0155
@ -1363,12 +1363,12 @@
|
|||||||
(NilCheck (Load (OffPtr [c] (SP)) (StaticCall {sym} _)) _)
|
(NilCheck (Load (OffPtr [c] (SP)) (StaticCall {sym} _)) _)
|
||||||
&& isSameSym(sym, "runtime.newobject")
|
&& isSameSym(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.Pos.Line() > 1, 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")
|
&& isSameSym(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.Pos.Line() > 1, v, "removed nil check")
|
&& warnRule(fe.Debug_checknil(), v, "removed nil check")
|
||||||
-> (Invalid)
|
-> (Invalid)
|
||||||
|
|
||||||
// Evaluate constant address comparisons.
|
// Evaluate constant address comparisons.
|
||||||
|
@ -646,11 +646,11 @@ func noteRule(s string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// warnRule generates a compiler debug output with string s when
|
// warnRule generates compiler debug output with string s when
|
||||||
// cond is true and the rule is fired.
|
// v is not in autogenerated code, cond is true and the rule has fired.
|
||||||
func warnRule(cond bool, v *Value, s string) bool {
|
func warnRule(cond bool, v *Value, s string) bool {
|
||||||
if cond {
|
if pos := v.Pos; pos.Line() > 1 && cond {
|
||||||
v.Block.Func.Warnl(v.Pos, s)
|
v.Block.Func.Warnl(pos, s)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -21412,7 +21412,7 @@ func rewriteValuegeneric_OpNilCheck_0(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.Pos.Line() > 1, v, "removed nil check")
|
// cond: isSameSym(sym, "runtime.newobject") && c == config.ctxt.FixedFrameSize() + config.RegSize && warnRule(fe.Debug_checknil(), v, "removed nil check")
|
||||||
// result: (Invalid)
|
// result: (Invalid)
|
||||||
for {
|
for {
|
||||||
_ = v.Args[1]
|
_ = v.Args[1]
|
||||||
@ -21435,14 +21435,14 @@ func rewriteValuegeneric_OpNilCheck_0(v *Value) bool {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
sym := v_0_1.Aux
|
sym := v_0_1.Aux
|
||||||
if !(isSameSym(sym, "runtime.newobject") && c == config.ctxt.FixedFrameSize()+config.RegSize && warnRule(fe.Debug_checknil() && v.Pos.Line() > 1, v, "removed nil check")) {
|
if !(isSameSym(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.Pos.Line() > 1, v, "removed nil check")
|
// cond: isSameSym(sym, "runtime.newobject") && c == config.ctxt.FixedFrameSize() + config.RegSize && warnRule(fe.Debug_checknil(), v, "removed nil check")
|
||||||
// result: (Invalid)
|
// result: (Invalid)
|
||||||
for {
|
for {
|
||||||
_ = v.Args[1]
|
_ = v.Args[1]
|
||||||
@ -21469,7 +21469,7 @@ func rewriteValuegeneric_OpNilCheck_0(v *Value) bool {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
sym := v_0_0_1.Aux
|
sym := v_0_0_1.Aux
|
||||||
if !(isSameSym(sym, "runtime.newobject") && c == config.ctxt.FixedFrameSize()+config.RegSize && warnRule(fe.Debug_checknil() && v.Pos.Line() > 1, v, "removed nil check")) {
|
if !(isSameSym(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)
|
||||||
|
Loading…
Reference in New Issue
Block a user