Commit 25946645 authored by Håvard Haugen's avatar Håvard Haugen Committed by Brad Fitzpatrick

cmd/compile/internal/gc: unexport and make Hasdefer a bool

Passes go build -a -toolexec 'toolstash -cmp' std cmd.

Change-Id: I804ee4252fa9be78cb277faf7f467e6c9cfdd4a6
Reviewed-on: https://go-review.googlesource.com/14319
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 704e05c6
...@@ -2399,7 +2399,7 @@ func Ginscall(f *Node, proc int) { ...@@ -2399,7 +2399,7 @@ func Ginscall(f *Node, proc int) {
if proc == 1 { if proc == 1 {
Ginscall(Newproc, 0) Ginscall(Newproc, 0)
} else { } else {
if Hasdefer == 0 { if !hasdefer {
Fatalf("hasdefer=0 but has defer") Fatalf("hasdefer=0 but has defer")
} }
Ginscall(Deferproc, 0) Ginscall(Deferproc, 0)
...@@ -2622,7 +2622,7 @@ func cgen_ret(n *Node) { ...@@ -2622,7 +2622,7 @@ func cgen_ret(n *Node) {
if n != nil { if n != nil {
Genlist(n.List) // copy out args Genlist(n.List) // copy out args
} }
if Hasdefer != 0 { if hasdefer {
Ginscall(Deferreturn, 0) Ginscall(Deferreturn, 0)
} }
Genlist(Curfn.Func.Exit) Genlist(Curfn.Func.Exit)
......
...@@ -616,7 +616,7 @@ var blockgen int32 // max block number ...@@ -616,7 +616,7 @@ var blockgen int32 // max block number
var block int32 // current block number var block int32 // current block number
var Hasdefer int // flag that curfn has defer statetment var hasdefer bool // flag that curfn has defer statement
var Curfn *Node var Curfn *Node
......
...@@ -392,7 +392,7 @@ func compile(fn *Node) { ...@@ -392,7 +392,7 @@ func compile(fn *Node) {
goto ret goto ret
} }
Hasdefer = 0 hasdefer = false
walk(Curfn) walk(Curfn)
if nerrors != 0 { if nerrors != 0 {
goto ret goto ret
...@@ -487,7 +487,7 @@ func compile(fn *Node) { ...@@ -487,7 +487,7 @@ func compile(fn *Node) {
// TODO: Determine when the final cgen_ret can be omitted. Perhaps always? // TODO: Determine when the final cgen_ret can be omitted. Perhaps always?
cgen_ret(nil) cgen_ret(nil)
if Hasdefer != 0 { if hasdefer {
// deferreturn pretends to have one uintptr argument. // deferreturn pretends to have one uintptr argument.
// Reserve space for it so stack scanner is happy. // Reserve space for it so stack scanner is happy.
if Maxarg < int64(Widthptr) { if Maxarg < int64(Widthptr) {
......
...@@ -486,7 +486,7 @@ func mkvar(f *Flow, a *obj.Addr) Bits { ...@@ -486,7 +486,7 @@ func mkvar(f *Flow, a *obj.Addr) Bits {
// //
// Disable registerization for results if using defer, because the deferred func // Disable registerization for results if using defer, because the deferred func
// might recover and return, causing the current values to be used. // might recover and return, causing the current values to be used.
if node.Class == PEXTERN || (Hasdefer != 0 && node.Class == PPARAMOUT) { if node.Class == PEXTERN || (hasdefer && node.Class == PPARAMOUT) {
v.addr = 1 v.addr = 1
} }
......
...@@ -231,7 +231,7 @@ func walkstmt(np **Node) { ...@@ -231,7 +231,7 @@ func walkstmt(np **Node) {
walkstmt(&n.Right) walkstmt(&n.Right)
case ODEFER: case ODEFER:
Hasdefer = 1 hasdefer = true
switch n.Left.Op { switch n.Left.Op {
case OPRINT, OPRINTN: case OPRINT, OPRINTN:
walkprintfunc(&n.Left, &n.Ninit) walkprintfunc(&n.Left, &n.Ninit)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment