cmd/compile: don't nilcheck newobject and return values from mapaccess{1,2}

They are guaranteed to be non-nil, no point in inserting
nil checks for them.

Fixes #15390

Change-Id: I3b9a0f2319affc2139dcc446d0a56c6785ae5a86
Reviewed-on: https://go-review.googlesource.com/22291
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
diff --git a/src/cmd/compile/internal/gc/walk.go b/src/cmd/compile/internal/gc/walk.go
index 0e74365..27ff045 100644
--- a/src/cmd/compile/internal/gc/walk.go
+++ b/src/cmd/compile/internal/gc/walk.go
@@ -886,6 +886,7 @@
 		if !isblank(a) {
 			var_ := temp(Ptrto(t.Val()))
 			var_.Typecheck = 1
+			var_.NonNil = true // mapaccess always returns a non-nil pointer
 			n.List.SetIndex(0, var_)
 			n = walkexpr(n, init)
 			init.Append(n)
@@ -895,8 +896,6 @@
 		n = typecheck(n, Etop)
 		n = walkexpr(n, init)
 
-		// TODO: ptr is always non-nil, so disable nil check for this OIND op.
-
 	case ODELETE:
 		init.AppendNodes(&n.Ninit)
 		map_ := n.List.First()
@@ -1224,7 +1223,6 @@
 			// standard version takes key by reference.
 			// orderexpr made sure key is addressable.
 			key = Nod(OADDR, n.Right, nil)
-
 			p = "mapaccess1"
 		}
 
@@ -1235,6 +1233,7 @@
 			z := zeroaddr(w)
 			n = mkcall1(mapfn(p, t), Ptrto(t.Val()), init, typename(t), n.Left, key, z)
 		}
+		n.NonNil = true // mapaccess always returns a non-nil pointer
 		n = Nod(OIND, n, nil)
 		n.Type = t.Val()
 		n.Typecheck = 1
@@ -2015,7 +2014,9 @@
 	dowidth(t)
 	fn := syslook("newobject")
 	fn = substArgTypes(fn, t)
-	return mkcall1(fn, Ptrto(t), nil, typename(t))
+	v := mkcall1(fn, Ptrto(t), nil, typename(t))
+	v.NonNil = true
+	return v
 }
 
 func iscallret(n *Node) bool {