From: Keith Randall Date: Sat, 19 Sep 2015 05:12:38 +0000 (-0700) Subject: [dev.ssa] cmd/compile: implement OSTRUCTLIT and OARRAYLIT X-Git-Tag: go1.7beta1~1623^2^2~155 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d3886906b18d292643117b55c987ec9b35b226b3;p=gostls13.git [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 Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go index 186c1a2996..fb7e0c54ac 100644 --- a/src/cmd/compile/internal/gc/ssa.go +++ b/src/cmd/compile/internal/gc/ssa.go @@ -574,7 +574,16 @@ func (s *state) stmt(n *Node) { } 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!