Commit 669fa8f3 authored by Alexey Naidonov's avatar Alexey Naidonov Committed by Keith Randall

cmd/compile: remove unnecessary nil-check

Removes unnecessary nil-check when referencing offset from an
address. Suggested by Keith Randall in golang/go#27180.

Updates golang/go#27180

Change-Id: I326ed7fda7cfa98b7e4354c811900707fee26021
Reviewed-on: https://go-review.googlesource.com/131735Reviewed-by: 's avatarKeith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 24e51bbe
......@@ -47,7 +47,7 @@ func nilcheckelim(f *Func) {
// a value resulting from taking the address of a
// value, or a value constructed from an offset of a
// non-nil ptr (OpAddPtr) implies it is non-nil
if v.Op == OpAddr || v.Op == OpLocalAddr || v.Op == OpAddPtr {
if v.Op == OpAddr || v.Op == OpLocalAddr || v.Op == OpAddPtr || v.Op == OpOffPtr {
nonNilValues[v.ID] = true
}
}
......
......@@ -246,8 +246,8 @@ type TT struct {
func f(t *TT) *byte {
// See issue 17242.
s := &t.SS // ERROR "removed nil check"
return &s.x // ERROR "generated nil check"
s := &t.SS // ERROR "generated nil check"
return &s.x // ERROR "removed nil check"
}
// make sure not to do nil check for newobject
......
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