aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/export_test.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2016-03-28 11:25:17 -0700
committerKeith Randall <khr@golang.org>2016-03-31 22:18:26 +0000
commit4a7aba775d6886109e0d4117d8c0a02112568686 (patch)
tree6e04167acfe2b55efd377ff6b5f31f293f298be2 /src/cmd/compile/internal/ssa/export_test.go
parente55896b9f421aeb6c33056a7cf6d7f90f8e36365 (diff)
downloadgo-4a7aba775d6886109e0d4117d8c0a02112568686.tar.gz
go-4a7aba775d6886109e0d4117d8c0a02112568686.zip
cmd/compile: better job of naming compound types
Compound AUTO types weren't named previously. That was because live variable analysis (plive.go) doesn't handle spilling to compound types. It can't handle them because there is no valid place to put VARDEFs when regalloc is spilling compound types. compound types = multiword builtin types: complex, string, slice, and interface. Instead, we split named AUTOs into individual one-word variables. For example, a string s gets split into a byte ptr s.ptr and an integer s.len. Those two variables can be spilled to / restored from independently. As a result, live variable analysis can handle them because they are one-word objects. This CL will change how AUTOs are described in DWARF information. Consider the code: func f(s string, i int) int { x := s[i:i+5] g() return lookup(x) } The old compiler would spill x to two consecutive slots on the stack, both named x (at offsets 0 and 8). The new compiler spills the pointer of x to a slot named x.ptr. It doesn't spill x.len at all, as it is a constant (5) and can be rematerialized for the call to lookup. So compound objects may not be spilled in their entirety, and even if they are they won't necessarily be contiguous. Such is the price of optimization. Re-enable live variable analysis tests. One test remains disabled, it fails because of #14904. Change-Id: I8ef2b5ab91e43a0d2136bfc231c05d100ec0b801 Reviewed-on: https://go-review.googlesource.com/21233 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/export_test.go')
-rw-r--r--src/cmd/compile/internal/ssa/export_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/export_test.go b/src/cmd/compile/internal/ssa/export_test.go
index a1f7910398..ce577ef055 100644
--- a/src/cmd/compile/internal/ssa/export_test.go
+++ b/src/cmd/compile/internal/ssa/export_test.go
@@ -31,6 +31,23 @@ func (DummyFrontend) StringData(s string) interface{} {
func (DummyFrontend) Auto(t Type) GCNode {
return nil
}
+func (d DummyFrontend) SplitString(s LocalSlot) (LocalSlot, LocalSlot) {
+ return LocalSlot{s.N, d.TypeBytePtr(), s.Off}, LocalSlot{s.N, d.TypeInt(), s.Off + 8}
+}
+func (d DummyFrontend) SplitInterface(s LocalSlot) (LocalSlot, LocalSlot) {
+ return LocalSlot{s.N, d.TypeBytePtr(), s.Off}, LocalSlot{s.N, d.TypeBytePtr(), s.Off + 8}
+}
+func (d DummyFrontend) SplitSlice(s LocalSlot) (LocalSlot, LocalSlot, LocalSlot) {
+ return LocalSlot{s.N, s.Type.ElemType().PtrTo(), s.Off},
+ LocalSlot{s.N, d.TypeInt(), s.Off + 8},
+ LocalSlot{s.N, d.TypeInt(), s.Off + 16}
+}
+func (d DummyFrontend) SplitComplex(s LocalSlot) (LocalSlot, LocalSlot) {
+ if s.Type.Size() == 16 {
+ return LocalSlot{s.N, d.TypeFloat64(), s.Off}, LocalSlot{s.N, d.TypeFloat64(), s.Off + 8}
+ }
+ return LocalSlot{s.N, d.TypeFloat32(), s.Off}, LocalSlot{s.N, d.TypeFloat32(), s.Off + 4}
+}
func (DummyFrontend) Line(line int32) string {
return "unknown.go:0"
}