summaryrefslogtreecommitdiff
path: root/test/escape_param.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2019-08-30 10:56:30 -0700
committerMatthew Dempsky <mdempsky@google.com>2019-09-03 17:52:06 +0000
commit9f89edcd9668bb3b011961fbcdd8fc2796acba5d (patch)
treefac2ea3d67038eff5b913af5cb6b24224c94767f /test/escape_param.go
parenta71967e4c5aa34f274b8b9aff915f14ac00e7ee8 (diff)
downloadgo-git-9f89edcd9668bb3b011961fbcdd8fc2796acba5d.tar.gz
cmd/compile: silence esc diagnostics about directiface OCONVIFACEs
In general, a conversion to interface type may require values to be boxed, which in turn necessitates escape analysis to determine whether the boxed representation can be stack allocated. However, esc.go used to unconditionally print escape analysis decisions about OCONVIFACE, even for conversions that don't require boxing (e.g., pointers, channels, maps, functions). For test compatibility with esc.go, escape.go similarly printed these useless diagnostics. This CL removes the diagnostics, and updates test expectations accordingly. Change-Id: I97c57a4a08e44d265bba516c78426ff4f2bf1e12 Reviewed-on: https://go-review.googlesource.com/c/go/+/192697 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'test/escape_param.go')
-rw-r--r--test/escape_param.go44
1 files changed, 22 insertions, 22 deletions
diff --git a/test/escape_param.go b/test/escape_param.go
index 76801aa08b..329d6d1c7f 100644
--- a/test/escape_param.go
+++ b/test/escape_param.go
@@ -27,7 +27,7 @@ func caller0a() {
func caller0b() {
i := 0 // ERROR "moved to heap: i$"
- sink = param0(&i) // ERROR "param0\(&i\) escapes to heap"
+ sink = param0(&i)
}
// in, in -> out, out
@@ -57,7 +57,7 @@ func caller2b() {
i := 0 // ERROR "moved to heap: i$"
var p *int
param2(&i, &p)
- sink = p // ERROR "p escapes to heap$"
+ sink = p
}
func paramArraySelfAssign(p *PairOfPairs) { // ERROR "p does not escape"
@@ -88,27 +88,27 @@ func leakParam(x interface{}) { // ERROR "leaking param: x"
func sinkAfterSelfAssignment1(box *BoxedPair) { // ERROR "leaking param content: box"
box.pair.p1 = box.pair.p2 // ERROR "ignoring self-assignment in box.pair.p1 = box.pair.p2"
- sink = box.pair.p2 // ERROR "box.pair.p2 escapes to heap"
+ sink = box.pair.p2
}
func sinkAfterSelfAssignment2(box *BoxedPair) { // ERROR "leaking param content: box"
box.pair.p1 = box.pair.p2 // ERROR "ignoring self-assignment in box.pair.p1 = box.pair.p2"
- sink = box.pair // ERROR "box.pair escapes to heap"
+ sink = box.pair
}
func sinkAfterSelfAssignment3(box *BoxedPair) { // ERROR "leaking param content: box"
box.pair.p1 = box.pair.p2 // ERROR "ignoring self-assignment in box.pair.p1 = box.pair.p2"
- leakParam(box.pair.p2) // ERROR "box.pair.p2 escapes to heap"
+ leakParam(box.pair.p2)
}
func sinkAfterSelfAssignment4(box *BoxedPair) { // ERROR "leaking param content: box"
box.pair.p1 = box.pair.p2 // ERROR "ignoring self-assignment in box.pair.p1 = box.pair.p2"
- leakParam(box.pair) // ERROR "box.pair escapes to heap"
+ leakParam(box.pair)
}
func selfAssignmentAndUnrelated(box1, box2 *BoxedPair) { // ERROR "leaking param content: box2" "box1 does not escape"
box1.pair.p1 = box1.pair.p2 // ERROR "ignoring self-assignment in box1.pair.p1 = box1.pair.p2"
- leakParam(box2.pair.p2) // ERROR "box2.pair.p2 escapes to heap"
+ leakParam(box2.pair.p2)
}
func notSelfAssignment1(box1, box2 *BoxedPair) { // ERROR "leaking param content: box2" "box1 does not escape"
@@ -178,7 +178,7 @@ func caller4b() {
// in -> heap
func param5(i *int) { // ERROR "leaking param: i$"
- sink = i // ERROR "i escapes to heap$"
+ sink = i
}
func caller5() {
@@ -188,7 +188,7 @@ func caller5() {
// *in -> heap
func param6(i ***int) { // ERROR "leaking param content: i$"
- sink = *i // ERROR "\*i escapes to heap$"
+ sink = *i
}
func caller6a() {
@@ -200,7 +200,7 @@ func caller6a() {
// **in -> heap
func param7(i ***int) { // ERROR "leaking param content: i$"
- sink = **i // ERROR "\* \(\*i\) escapes to heap"
+ sink = **i
}
func caller7() {
@@ -237,7 +237,7 @@ func caller9b() {
i := 0 // ERROR "moved to heap: i$"
p := &i // ERROR "moved to heap: p$"
p2 := &p
- sink = param9(&p2) // ERROR "param9\(&p2\) escapes to heap"
+ sink = param9(&p2)
}
// **in -> out
@@ -256,7 +256,7 @@ func caller10b() {
i := 0 // ERROR "moved to heap: i$"
p := &i
p2 := &p
- sink = param10(&p2) // ERROR "param10\(&p2\) escapes to heap"
+ sink = param10(&p2)
}
// in escapes to heap (address of param taken and returned)
@@ -273,20 +273,20 @@ func caller11a() {
func caller11b() {
i := 0 // ERROR "moved to heap: i$"
p := &i // ERROR "moved to heap: p$"
- sink = param11(&p) // ERROR "param11\(&p\) escapes to heap"
+ sink = param11(&p)
}
func caller11c() { // GOOD
i := 0 // ERROR "moved to heap: i$"
p := &i // ERROR "moved to heap: p"
- sink = *param11(&p) // ERROR "\*param11\(&p\) escapes to heap"
+ sink = *param11(&p)
}
func caller11d() {
i := 0 // ERROR "moved to heap: i$"
p := &i // ERROR "moved to heap: p"
p2 := &p
- sink = param11(p2) // ERROR "param11\(p2\) escapes to heap"
+ sink = param11(p2)
}
// &in -> rcvr
@@ -319,7 +319,7 @@ func caller12c() {
p := &i // ERROR "moved to heap: p$"
r := Indir{}
r.param12(&p)
- sink = r // ERROR "r escapes to heap$"
+ sink = r
}
func caller12d() {
@@ -327,7 +327,7 @@ func caller12d() {
p := &i // ERROR "moved to heap: p$"
r := Indir{}
r.param12(&p)
- sink = **r.p // ERROR "\* \(\*r\.p\) escapes to heap"
+ sink = **r.p
}
// in -> value rcvr
@@ -370,7 +370,7 @@ func caller13d() {
var v Val
v.p = &p
v.param13(&i)
- sink = v // ERROR "v escapes to heap$"
+ sink = v
}
func caller13e() {
@@ -378,7 +378,7 @@ func caller13e() {
var p *int // ERROR "moved to heap: p$"
v := Val{&p}
v.param13(&i)
- sink = v // ERROR "v escapes to heap$"
+ sink = v
}
func caller13f() {
@@ -386,7 +386,7 @@ func caller13f() {
var p *int // ERROR "moved to heap: p$"
v := &Val{&p} // ERROR "&Val literal escapes to heap$"
v.param13(&i)
- sink = v // ERROR "v escapes to heap$"
+ sink = v
}
func caller13g() {
@@ -394,7 +394,7 @@ func caller13g() {
var p *int
v := Val{&p}
v.param13(&i)
- sink = *v.p // ERROR "\*v\.p escapes to heap"
+ sink = *v.p
}
func caller13h() {
@@ -437,5 +437,5 @@ func param14a(x [4]*int) interface{} { // ERROR "leaking param: x$"
// Convert to a direct interface, does not need an allocation.
// So x only leaks to result.
func param14b(x *int) interface{} { // ERROR "leaking param: x to result ~r1 level=0"
- return x // ERROR "x escapes to heap"
+ return x
}