1
0
mirror of https://github.com/golang/go synced 2024-11-21 18:04:40 -07:00

cmd/gc: must not inline panic, recover

R=lvd, gri
CC=golang-dev
https://golang.org/cl/5731061
This commit is contained in:
Russ Cox 2012-03-05 13:51:44 -05:00
parent 5ab9d2befd
commit cae604f734
2 changed files with 15 additions and 7 deletions

View File

@ -182,6 +182,8 @@ ishairy(Node *n, int *budget)
case OCALLFUNC: case OCALLFUNC:
case OCALLINTER: case OCALLINTER:
case OCALLMETH: case OCALLMETH:
case OPANIC:
case ORECOVER:
if(debug['l'] < 4) if(debug['l'] < 4)
return 1; return 1;
break; break;

View File

@ -11,8 +11,8 @@ package foo
var p *int var p *int
func alloc(x int) *int { // ERROR "can inline alloc" "moved to heap: x" func alloc(x int) *int { // ERROR "can inline alloc" "moved to heap: x"
return &x // ERROR "&x escapes to heap" return &x // ERROR "&x escapes to heap"
} }
var f func() var f func()
@ -22,12 +22,18 @@ func f1() {
// Escape analysis used to miss inlined code in closures. // Escape analysis used to miss inlined code in closures.
func() { // ERROR "func literal does not escape" func() { // ERROR "func literal does not escape"
p = alloc(3) // ERROR "inlining call to alloc" "&x escapes to heap" "moved to heap: x" p = alloc(3) // ERROR "inlining call to alloc" "&x escapes to heap" "moved to heap: x"
}() }()
f = func() { // ERROR "func literal escapes to heap" f = func() { // ERROR "func literal escapes to heap"
p = alloc(3) // ERROR "inlining call to alloc" "&x escapes to heap" "moved to heap: x" p = alloc(3) // ERROR "inlining call to alloc" "&x escapes to heap" "moved to heap: x"
} }
f() f()
} }
func f2() {} // ERROR "can inline f2"
// No inline for panic, recover.
func f3() { panic(1) }
func f4() { recover() }