summaryrefslogtreecommitdiff
path: root/test/escape2.go
diff options
context:
space:
mode:
authorLuuk van Dijk <lvd@golang.org>2012-10-29 13:38:21 +0100
committerLuuk van Dijk <lvd@golang.org>2012-10-29 13:38:21 +0100
commit035b3bc226d6615af3442c6b6866e42cea07c3c3 (patch)
tree0b081ff28e7f63bf3abc66ab51ec91ccbf7ccdfe /test/escape2.go
parent09858a676100a50e551f4286f0a968e7163b83a7 (diff)
downloadgo-035b3bc226d6615af3442c6b6866e42cea07c3c3.tar.gz
cmd/gc: escape analysis to track flow of in to out parameters.
includes step 0: synthesize outparams, from 6600044 includes step 1,2: give outparams loopdepth 0 and verify unchanged results generate esc:$mask tags, but still tie to sink if a param has mask != 0 from 6610054 adds final steps: - have esccall generate n->escretval, a list of nodes the function results flow to - use these in esccall and ORETURN/OAS2FUNC/and f(g()) - only tie parameters to sink if tag is absent, otherwise according to mask, tie them to escretval R=rsc, bradfitz CC=dave, gobot, golang-dev, iant, rsc http://codereview.appspot.com/6741044
Diffstat (limited to 'test/escape2.go')
-rw-r--r--test/escape2.go26
1 files changed, 20 insertions, 6 deletions
diff --git a/test/escape2.go b/test/escape2.go
index 8db12d991..bfc90ecb4 100644
--- a/test/escape2.go
+++ b/test/escape2.go
@@ -561,12 +561,21 @@ func myprint1(y *int, x ...interface{}) *interface{} { // ERROR "y does not esca
return &x[0] // ERROR "&x.0. escapes to heap"
}
-func foo75(z *int) { // ERROR "leaking param: z"
+func foo75(z *int) { // ERROR "z does not escape"
myprint(z, 1, 2, 3) // ERROR "[.][.][.] argument does not escape"
}
func foo75a(z *int) { // ERROR "z does not escape"
- myprint1(z, 1, 2, 3) // ERROR "[.][.][.] argument escapes to heap"
+ myprint1(z, 1, 2, 3) // ERROR "[.][.][.] argument does not escape"
+}
+
+func foo75esc(z *int) { // ERROR "leaking param: z"
+ gxx = myprint(z, 1, 2, 3) // ERROR "[.][.][.] argument does not escape"
+}
+
+func foo75aesc(z *int) { // ERROR "z does not escape"
+ var ppi **interface{} // assignments to pointer dereferences lose track
+ *ppi = myprint1(z, 1, 2, 3) // ERROR "[.][.][.] argument escapes to heap"
}
func foo76(z *int) { // ERROR "leaking param: z"
@@ -574,7 +583,7 @@ func foo76(z *int) { // ERROR "leaking param: z"
}
func foo76a(z *int) { // ERROR "leaking param: z"
- myprint1(nil, z) // ERROR "[.][.][.] argument escapes to heap"
+ myprint1(nil, z) // ERROR "[.][.][.] argument does not escape"
}
func foo76b() {
@@ -582,7 +591,7 @@ func foo76b() {
}
func foo76c() {
- myprint1(nil, 1, 2, 3) // ERROR "[.][.][.] argument escapes to heap"
+ myprint1(nil, 1, 2, 3) // ERROR "[.][.][.] argument does not escape"
}
func foo76d() {
@@ -590,7 +599,7 @@ func foo76d() {
}
func foo76e() {
- defer myprint1(nil, 1, 2, 3) // ERROR "[.][.][.] argument escapes to heap"
+ defer myprint1(nil, 1, 2, 3) // ERROR "[.][.][.] argument does not escape"
}
func foo76f() {
@@ -610,10 +619,15 @@ func foo77(z []interface{}) { // ERROR "z does not escape"
myprint(nil, z...) // z does not escape
}
-func foo77a(z []interface{}) { // ERROR "leaking param: z"
+func foo77a(z []interface{}) { // ERROR "z does not escape"
myprint1(nil, z...)
}
+func foo77b(z []interface{}) { // ERROR "leaking param: z"
+ var ppi **interface{}
+ *ppi = myprint1(nil, z...)
+}
+
func foo78(z int) *int { // ERROR "moved to heap: z"
return &z // ERROR "&z escapes to heap"
}