aboutsummaryrefslogtreecommitdiff
path: root/test/live1.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-02-13 23:33:20 -0500
committerRuss Cox <rsc@golang.org>2014-02-13 23:33:20 -0500
commit02ae91f3424d45820a5b98ddc2595680666a97e0 (patch)
tree6abfac1843cb788b43fb52d2f107ebb2216e27e0 /test/live1.go
parent91b1f7cb15700f39ca63c4e056b41d9b04100e97 (diff)
downloadgo-02ae91f3424d45820a5b98ddc2595680666a97e0.tar.gz
go-02ae91f3424d45820a5b98ddc2595680666a97e0.zip
cmd/gc: correct liveness for wrappers containing tail jumps
A normal RET is treated as using the return values, but a tail jump RET does not - it is jumping to the function that is going to fill in the return values. If a tail jump RET is recorded as using the return values, since nothing initializes them they will be marked as live on entry to the function, which is clearly wrong. Found and tested by the new code in plive.c that looks for variables that are incorrectly live on entry. That code is disabled for now because there are other cases remaining to be fixed. But once it is enabled, test/live1.go becomes a real test of this CL. TBR=iant CC=golang-codereviews https://golang.org/cl/63570045
Diffstat (limited to 'test/live1.go')
-rw-r--r--test/live1.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/live1.go b/test/live1.go
new file mode 100644
index 0000000000..d0a2d0ecf5
--- /dev/null
+++ b/test/live1.go
@@ -0,0 +1,30 @@
+// compile
+
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test that code compiles without
+// "internal error: ... recorded as live on entry" errors
+// from the liveness code.
+
+package main
+
+// The liveness analysis used to get confused by the tail return
+// instruction in the wrapper methods generated for T1.M and (*T1).M,
+// causing a spurious "live at entry: ~r1" for the return result.
+// This test is checking that there is no such message.
+// We cannot use live.go because it runs with -live on, which will
+// generate (correct) messages about the wrapper's receivers
+// being live on entry, but those messages correspond to no
+// source line in the file, so they are given at line 1, which we
+// cannot annotate. Not using -live here avoids that problem.
+
+type T struct {
+}
+
+func (t *T) M() *int
+
+type T1 struct {
+ *T
+}