aboutsummaryrefslogtreecommitdiff
path: root/test/escape_struct_param2.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2019-04-01 11:58:33 -0700
committerMatthew Dempsky <mdempsky@google.com>2019-04-02 16:34:03 +0000
commitabefcac10a635c5c6afdeada810f4663e6cb6f17 (patch)
tree1361a49965e3c1d19795abfc1734d3b262455ee8 /test/escape_struct_param2.go
parent4ebc6514faa8530d1a68b4e04f57dc5c25bcb01c (diff)
downloadgo-abefcac10a635c5c6afdeada810f4663e6cb6f17.tar.gz
go-abefcac10a635c5c6afdeada810f4663e6cb6f17.zip
cmd/compile: skip escape analysis diagnostics for OADDR
For most nodes (e.g., OPTRLIT, OMAKESLICE, OCONVIFACE), escape analysis prints "escapes to heap" or "does not escape" to indicate whether that node's allocation can be heap or stack allocated. These messages are also emitted for OADDR, even though OADDR does not actually allocate anything itself. Moreover, it's redundant because escape analysis already prints "moved to heap" diagnostics when an OADDR node like "&x" causes x to require heap allocation. Because OADDR nodes don't allocate memory, my escape analysis rewrite doesn't naturally emit the "escapes to heap" / "does not escape" diagnostics for them. It's also non-trivial to replicate the exact semantics esc.go uses for OADDR. Since there are so many of these messages, I'm disabling them in this CL by themselves. I modified esc.go to suppress the Warnl calls without any other behavior changes, and then used a shell script to automatically remove any ERROR messages mentioned by run.go in "missing error" or "no match for" lines. Fixes #16300. Updates #23109. Change-Id: I3993e2743c3ff83ccd0893f4e73b366ff8871a57 Reviewed-on: https://go-review.googlesource.com/c/go/+/170319 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'test/escape_struct_param2.go')
-rw-r--r--test/escape_struct_param2.go138
1 files changed, 69 insertions, 69 deletions
diff --git a/test/escape_struct_param2.go b/test/escape_struct_param2.go
index d5305d4f40..5a9b271958 100644
--- a/test/escape_struct_param2.go
+++ b/test/escape_struct_param2.go
@@ -36,16 +36,16 @@ func (u U) SPPi() *string { // ERROR "leaking param: u to result ~r0 level=1$"
func tSPPi() {
s := "cat" // ERROR "moved to heap: s$"
- ps := &s // ERROR "&s escapes to heap$"
- pps := &ps // ERROR "tSPPi &ps does not escape$"
+ ps := &s
+ pps := &ps
pu := &U{ps, pps} // ERROR "tSPPi &U literal does not escape$"
Ssink = pu.SPPi()
}
func tiSPP() {
s := "cat" // ERROR "moved to heap: s$"
- ps := &s // ERROR "&s escapes to heap$"
- pps := &ps // ERROR "tiSPP &ps does not escape$"
+ ps := &s
+ pps := &ps
pu := &U{ps, pps} // ERROR "tiSPP &U literal does not escape$"
Ssink = *pu.SPP()
}
@@ -53,8 +53,8 @@ func tiSPP() {
// BAD: need fine-grained analysis to avoid spurious escape of ps
func tSP() {
s := "cat" // ERROR "moved to heap: s$"
- ps := &s // ERROR "&s escapes to heap$" "moved to heap: ps$"
- pps := &ps // ERROR "&ps escapes to heap$"
+ ps := &s // ERROR "moved to heap: ps$"
+ pps := &ps
pu := &U{ps, pps} // ERROR "tSP &U literal does not escape$"
Ssink = pu.SP()
}
@@ -119,13 +119,13 @@ func tUPiSPa() {
s4 := "dog" // ERROR "moved to heap: s4$"
s5 := "emu" // ERROR "moved to heap: s5$"
s6 := "fox" // ERROR "moved to heap: s6$"
- ps2 := &s2 // ERROR "&s2 escapes to heap$"
- ps4 := &s4 // ERROR "&s4 escapes to heap$" "moved to heap: ps4$"
- ps6 := &s6 // ERROR "&s6 escapes to heap$" "moved to heap: ps6$"
- u1 := U{&s1, &ps2} // ERROR "tUPiSPa &ps2 does not escape$" "tUPiSPa &s1 does not escape$"
- u2 := &U{&s3, &ps4} // ERROR "&ps4 escapes to heap$" "&s3 escapes to heap$" "tUPiSPa &U literal does not escape$"
- u3 := &U{&s5, &ps6} // ERROR "&U literal escapes to heap$" "&ps6 escapes to heap$" "&s5 escapes to heap$"
- v := &V{u1, u2, &u3} // ERROR "tUPiSPa &V literal does not escape$" "tUPiSPa &u3 does not escape$"
+ ps2 := &s2
+ ps4 := &s4 // ERROR "moved to heap: ps4$"
+ ps6 := &s6 // ERROR "moved to heap: ps6$"
+ u1 := U{&s1, &ps2}
+ u2 := &U{&s3, &ps4} // ERROR "tUPiSPa &U literal does not escape$"
+ u3 := &U{&s5, &ps6} // ERROR "&U literal escapes to heap$"
+ v := &V{u1, u2, &u3} // ERROR "tUPiSPa &V literal does not escape$"
Ssink = v.UPiSPa() // Ssink = &s3 (only &s3 really escapes)
}
@@ -137,13 +137,13 @@ func tUPiSPb() {
s4 := "dog" // ERROR "moved to heap: s4$"
s5 := "emu" // ERROR "moved to heap: s5$"
s6 := "fox" // ERROR "moved to heap: s6$"
- ps2 := &s2 // ERROR "&s2 escapes to heap$"
- ps4 := &s4 // ERROR "&s4 escapes to heap$" "moved to heap: ps4$"
- ps6 := &s6 // ERROR "&s6 escapes to heap$" "moved to heap: ps6$"
- u1 := U{&s1, &ps2} // ERROR "tUPiSPb &ps2 does not escape$" "tUPiSPb &s1 does not escape$"
- u2 := &U{&s3, &ps4} // ERROR "&ps4 escapes to heap$" "&s3 escapes to heap$" "tUPiSPb &U literal does not escape$"
- u3 := &U{&s5, &ps6} // ERROR "&U literal escapes to heap$" "&ps6 escapes to heap$" "&s5 escapes to heap$"
- v := &V{u1, u2, &u3} // ERROR "tUPiSPb &V literal does not escape$" "tUPiSPb &u3 does not escape$"
+ ps2 := &s2
+ ps4 := &s4 // ERROR "moved to heap: ps4$"
+ ps6 := &s6 // ERROR "moved to heap: ps6$"
+ u1 := U{&s1, &ps2}
+ u2 := &U{&s3, &ps4} // ERROR "tUPiSPb &U literal does not escape$"
+ u3 := &U{&s5, &ps6} // ERROR "&U literal escapes to heap$"
+ v := &V{u1, u2, &u3} // ERROR "tUPiSPb &V literal does not escape$"
Ssink = v.UPiSPb() // Ssink = &s3 (only &s3 really escapes)
}
@@ -155,13 +155,13 @@ func tUPiSPc() {
s4 := "dog" // ERROR "moved to heap: s4$"
s5 := "emu" // ERROR "moved to heap: s5$"
s6 := "fox" // ERROR "moved to heap: s6$"
- ps2 := &s2 // ERROR "&s2 escapes to heap$"
- ps4 := &s4 // ERROR "&s4 escapes to heap$" "moved to heap: ps4$"
- ps6 := &s6 // ERROR "&s6 escapes to heap$" "moved to heap: ps6$"
- u1 := U{&s1, &ps2} // ERROR "tUPiSPc &ps2 does not escape$" "tUPiSPc &s1 does not escape$"
- u2 := &U{&s3, &ps4} // ERROR "&ps4 escapes to heap$" "&s3 escapes to heap$" "tUPiSPc &U literal does not escape$"
- u3 := &U{&s5, &ps6} // ERROR "&U literal escapes to heap$" "&ps6 escapes to heap$" "&s5 escapes to heap$"
- v := &V{u1, u2, &u3} // ERROR "tUPiSPc &V literal does not escape$" "tUPiSPc &u3 does not escape$"
+ ps2 := &s2
+ ps4 := &s4 // ERROR "moved to heap: ps4$"
+ ps6 := &s6 // ERROR "moved to heap: ps6$"
+ u1 := U{&s1, &ps2}
+ u2 := &U{&s3, &ps4} // ERROR "tUPiSPc &U literal does not escape$"
+ u3 := &U{&s5, &ps6} // ERROR "&U literal escapes to heap$"
+ v := &V{u1, u2, &u3} // ERROR "tUPiSPc &V literal does not escape$"
Ssink = v.UPiSPc() // Ssink = &s3 (only &s3 really escapes)
}
@@ -173,13 +173,13 @@ func tUPiSPd() {
s4 := "dog" // ERROR "moved to heap: s4$"
s5 := "emu" // ERROR "moved to heap: s5$"
s6 := "fox" // ERROR "moved to heap: s6$"
- ps2 := &s2 // ERROR "&s2 escapes to heap$"
- ps4 := &s4 // ERROR "&s4 escapes to heap$" "moved to heap: ps4$"
- ps6 := &s6 // ERROR "&s6 escapes to heap$" "moved to heap: ps6$"
- u1 := U{&s1, &ps2} // ERROR "tUPiSPd &ps2 does not escape$" "tUPiSPd &s1 does not escape$"
- u2 := &U{&s3, &ps4} // ERROR "&ps4 escapes to heap$" "&s3 escapes to heap$" "tUPiSPd &U literal does not escape$"
- u3 := &U{&s5, &ps6} // ERROR "&U literal escapes to heap$" "&ps6 escapes to heap$" "&s5 escapes to heap$"
- v := &V{u1, u2, &u3} // ERROR "tUPiSPd &V literal does not escape$" "tUPiSPd &u3 does not escape$"
+ ps2 := &s2
+ ps4 := &s4 // ERROR "moved to heap: ps4$"
+ ps6 := &s6 // ERROR "moved to heap: ps6$"
+ u1 := U{&s1, &ps2}
+ u2 := &U{&s3, &ps4} // ERROR "tUPiSPd &U literal does not escape$"
+ u3 := &U{&s5, &ps6} // ERROR "&U literal escapes to heap$"
+ v := &V{u1, u2, &u3} // ERROR "tUPiSPd &V literal does not escape$"
Ssink = v.UPiSPd() // Ssink = &s3 (only &s3 really escapes)
}
@@ -207,13 +207,13 @@ func tUPiSPPia() {
s4 := "dog" // ERROR "moved to heap: s4$"
s5 := "emu" // ERROR "moved to heap: s5$"
s6 := "fox" // ERROR "moved to heap: s6$"
- ps2 := &s2 // ERROR "tUPiSPPia &s2 does not escape$"
- ps4 := &s4 // ERROR "&s4 escapes to heap$"
- ps6 := &s6 // ERROR "&s6 escapes to heap$" "moved to heap: ps6$"
- u1 := U{&s1, &ps2} // ERROR "tUPiSPPia &ps2 does not escape$" "tUPiSPPia &s1 does not escape$"
- u2 := &U{&s3, &ps4} // ERROR "tUPiSPPia &U literal does not escape$" "tUPiSPPia &ps4 does not escape$" "tUPiSPPia &s3 does not escape$"
- u3 := &U{&s5, &ps6} // ERROR "&ps6 escapes to heap$" "&s5 escapes to heap$" "tUPiSPPia &U literal does not escape$"
- v := &V{u1, u2, &u3} // ERROR "tUPiSPPia &V literal does not escape$" "tUPiSPPia &u3 does not escape$"
+ ps2 := &s2
+ ps4 := &s4
+ ps6 := &s6 // ERROR "moved to heap: ps6$"
+ u1 := U{&s1, &ps2}
+ u2 := &U{&s3, &ps4} // ERROR "tUPiSPPia &U literal does not escape$"
+ u3 := &U{&s5, &ps6} // ERROR "tUPiSPPia &U literal does not escape$"
+ v := &V{u1, u2, &u3} // ERROR "tUPiSPPia &V literal does not escape$"
Ssink = v.UPiSPPia() // Ssink = *&ps4 = &s4 (only &s4 really escapes)
}
@@ -225,13 +225,13 @@ func tUPiSPPib() {
s4 := "dog" // ERROR "moved to heap: s4$"
s5 := "emu" // ERROR "moved to heap: s5$"
s6 := "fox" // ERROR "moved to heap: s6$"
- ps2 := &s2 // ERROR "tUPiSPPib &s2 does not escape$"
- ps4 := &s4 // ERROR "&s4 escapes to heap$"
- ps6 := &s6 // ERROR "&s6 escapes to heap$" "moved to heap: ps6$"
- u1 := U{&s1, &ps2} // ERROR "tUPiSPPib &ps2 does not escape$" "tUPiSPPib &s1 does not escape$"
- u2 := &U{&s3, &ps4} // ERROR "tUPiSPPib &U literal does not escape$" "tUPiSPPib &ps4 does not escape$" "tUPiSPPib &s3 does not escape$"
- u3 := &U{&s5, &ps6} // ERROR "&ps6 escapes to heap$" "&s5 escapes to heap$" "tUPiSPPib &U literal does not escape$"
- v := &V{u1, u2, &u3} // ERROR "tUPiSPPib &V literal does not escape$" "tUPiSPPib &u3 does not escape$"
+ ps2 := &s2
+ ps4 := &s4
+ ps6 := &s6 // ERROR "moved to heap: ps6$"
+ u1 := U{&s1, &ps2}
+ u2 := &U{&s3, &ps4} // ERROR "tUPiSPPib &U literal does not escape$"
+ u3 := &U{&s5, &ps6} // ERROR "tUPiSPPib &U literal does not escape$"
+ v := &V{u1, u2, &u3} // ERROR "tUPiSPPib &V literal does not escape$"
Ssink = v.UPiSPPib() // Ssink = *&ps4 = &s4 (only &s4 really escapes)
}
@@ -243,13 +243,13 @@ func tUPiSPPic() {
s4 := "dog" // ERROR "moved to heap: s4$"
s5 := "emu" // ERROR "moved to heap: s5$"
s6 := "fox" // ERROR "moved to heap: s6$"
- ps2 := &s2 // ERROR "tUPiSPPic &s2 does not escape$"
- ps4 := &s4 // ERROR "&s4 escapes to heap$"
- ps6 := &s6 // ERROR "&s6 escapes to heap$" "moved to heap: ps6$"
- u1 := U{&s1, &ps2} // ERROR "tUPiSPPic &ps2 does not escape$" "tUPiSPPic &s1 does not escape$"
- u2 := &U{&s3, &ps4} // ERROR "tUPiSPPic &U literal does not escape$" "tUPiSPPic &ps4 does not escape$" "tUPiSPPic &s3 does not escape$"
- u3 := &U{&s5, &ps6} // ERROR "&ps6 escapes to heap$" "&s5 escapes to heap$" "tUPiSPPic &U literal does not escape$"
- v := &V{u1, u2, &u3} // ERROR "tUPiSPPic &V literal does not escape$" "tUPiSPPic &u3 does not escape$"
+ ps2 := &s2
+ ps4 := &s4
+ ps6 := &s6 // ERROR "moved to heap: ps6$"
+ u1 := U{&s1, &ps2}
+ u2 := &U{&s3, &ps4} // ERROR "tUPiSPPic &U literal does not escape$"
+ u3 := &U{&s5, &ps6} // ERROR "tUPiSPPic &U literal does not escape$"
+ v := &V{u1, u2, &u3} // ERROR "tUPiSPPic &V literal does not escape$"
Ssink = v.UPiSPPic() // Ssink = *&ps4 = &s4 (only &s4 really escapes)
}
@@ -261,13 +261,13 @@ func tUPiSPPid() {
s4 := "dog" // ERROR "moved to heap: s4$"
s5 := "emu" // ERROR "moved to heap: s5$"
s6 := "fox" // ERROR "moved to heap: s6$"
- ps2 := &s2 // ERROR "tUPiSPPid &s2 does not escape$"
- ps4 := &s4 // ERROR "&s4 escapes to heap$"
- ps6 := &s6 // ERROR "&s6 escapes to heap$" "moved to heap: ps6$"
- u1 := U{&s1, &ps2} // ERROR "tUPiSPPid &ps2 does not escape$" "tUPiSPPid &s1 does not escape$"
- u2 := &U{&s3, &ps4} // ERROR "tUPiSPPid &U literal does not escape$" "tUPiSPPid &ps4 does not escape$" "tUPiSPPid &s3 does not escape$"
- u3 := &U{&s5, &ps6} // ERROR "&ps6 escapes to heap$" "&s5 escapes to heap$" "tUPiSPPid &U literal does not escape$"
- v := &V{u1, u2, &u3} // ERROR "tUPiSPPid &V literal does not escape$" "tUPiSPPid &u3 does not escape$"
+ ps2 := &s2
+ ps4 := &s4
+ ps6 := &s6 // ERROR "moved to heap: ps6$"
+ u1 := U{&s1, &ps2}
+ u2 := &U{&s3, &ps4} // ERROR "tUPiSPPid &U literal does not escape$"
+ u3 := &U{&s5, &ps6} // ERROR "tUPiSPPid &U literal does not escape$"
+ v := &V{u1, u2, &u3} // ERROR "tUPiSPPid &V literal does not escape$"
Ssink = v.UPiSPPid() // Ssink = *&ps4 = &s4 (only &s4 really escapes)
}
@@ -287,12 +287,12 @@ func tUPPiSPPia() { // This test is sensitive to the level cap in function summa
s4 := "dog"
s5 := "emu"
s6 := "fox" // ERROR "moved to heap: s6$"
- ps2 := &s2 // ERROR "tUPPiSPPia &s2 does not escape$"
- ps4 := &s4 // ERROR "tUPPiSPPia &s4 does not escape$"
- ps6 := &s6 // ERROR "&s6 escapes to heap$"
- u1 := U{&s1, &ps2} // ERROR "tUPPiSPPia &ps2 does not escape$" "tUPPiSPPia &s1 does not escape$"
- u2 := &U{&s3, &ps4} // ERROR "tUPPiSPPia &U literal does not escape$" "tUPPiSPPia &ps4 does not escape$" "tUPPiSPPia &s3 does not escape$"
- u3 := &U{&s5, &ps6} // ERROR "tUPPiSPPia &U literal does not escape$" "tUPPiSPPia &ps6 does not escape$" "tUPPiSPPia &s5 does not escape$"
- v := &V{u1, u2, &u3} // ERROR "tUPPiSPPia &V literal does not escape$" "tUPPiSPPia &u3 does not escape$"
+ ps2 := &s2
+ ps4 := &s4
+ ps6 := &s6
+ u1 := U{&s1, &ps2}
+ u2 := &U{&s3, &ps4} // ERROR "tUPPiSPPia &U literal does not escape$"
+ u3 := &U{&s5, &ps6} // ERROR "tUPPiSPPia &U literal does not escape$"
+ v := &V{u1, u2, &u3} // ERROR "tUPPiSPPia &V literal does not escape$"
Ssink = v.UPPiSPPia() // Ssink = *&ps6 = &s6 (only &s6 really escapes)
}