1
0
mirror of https://github.com/golang/go synced 2024-10-05 16:41:21 -06:00

[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>
This commit is contained in:
Keith Randall 2015-09-18 22:12:38 -07:00
parent b32217a273
commit d3886906b1

View File

@ -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!