cmd/compile: remove some uses of ir.CurFunc

This CL updates several frontend passes to stop relying on
ir.CurFunc (at least directly).

Change-Id: I3c3529e81e27fb05d54a828f081f7c7efc31af67
Reviewed-on: https://go-review.googlesource.com/c/go/+/520606
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Matthew Dempsky 2023-08-17 22:13:22 -07:00 committed by Gopher Robot
parent 78f90511ec
commit 89eb6b76ae
5 changed files with 25 additions and 28 deletions

View file

@ -107,7 +107,7 @@ func ForCapture(fn *ir.Func) []VarAndLoop {
if base.LoopVarHash.MatchPos(n.Pos(), desc) {
// Rename the loop key, prefix body with assignment from loop key
transformed = append(transformed, VarAndLoop{n, x, lastPos})
tk := typecheck.TempAt(base.Pos, ir.CurFunc, n.Type())
tk := typecheck.TempAt(base.Pos, fn, n.Type())
tk.SetTypecheck(1)
as := ir.NewAssignStmt(x.Pos(), n, tk)
as.Def = true
@ -298,7 +298,7 @@ func ForCapture(fn *ir.Func) []VarAndLoop {
for _, z := range leaked {
transformed = append(transformed, VarAndLoop{z, x, lastPos})
tz := typecheck.TempAt(base.Pos, ir.CurFunc, z.Type())
tz := typecheck.TempAt(base.Pos, fn, z.Type())
tz.SetTypecheck(1)
zPrimeForZ[z] = tz
@ -360,7 +360,7 @@ func ForCapture(fn *ir.Func) []VarAndLoop {
// body' = prebody +
// (6) if tmp_first {tmp_first = false} else {Post} +
// if !cond {break} + ...
tmpFirst := typecheck.TempAt(base.Pos, ir.CurFunc, types.Types[types.TBOOL])
tmpFirst := typecheck.TempAt(base.Pos, fn, types.Types[types.TBOOL])
// tmpFirstAssign assigns val to tmpFirst
tmpFirstAssign := func(val bool) *ir.AssignStmt {