[dev.ssa] cmd/compile: implement OSTRUCTLIT and OARRAYLIT

The frontend rewrites most literals, so we see only zero
ones during SSA construction.  We can implement those
using the existing zeroing behavior.

Change-Id: I390ad1be0a4b6729baf0c8936c7610aae2aef049
Reviewed-on: https://go-review.googlesource.com/14754
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go
index 186c1a2..fb7e0c5 100644
--- a/src/cmd/compile/internal/gc/ssa.go
+++ b/src/cmd/compile/internal/gc/ssa.go
@@ -574,7 +574,16 @@
 		}
 		var r *ssa.Value
 		if n.Right != nil {
-			r = s.expr(n.Right)
+			if n.Right.Op == OSTRUCTLIT || n.Right.Op == OARRAYLIT {
+				// All literals with nonzero fields have already been
+				// rewritten during walk.  Any that remain are just T{}
+				// or equivalents.  Leave r = nil to get zeroing behavior.
+				if !iszero(n.Right) {
+					Fatalf("literal with nonzero value in SSA: %v", n.Right)
+				}
+			} else {
+				r = s.expr(n.Right)
+			}
 		}
 		if n.Right != nil && n.Right.Op == OAPPEND {
 			// Yuck!  The frontend gets rid of the write barrier, but we need it!