From ae12e8f2c7ec636d64310d2265d3d31c8b0f3d1d Mon Sep 17 00:00:00 2001 From: Tim King Date: Sun, 24 Apr 2022 17:18:23 -0700 Subject: [PATCH] ssa: switch lblocks to types.Object MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Switches lblocks from *ast.Object to types.Object. Removes a user from the infrequently used *ast.Object. Updates golang/go#52463 Change-Id: I1a21ab55b7136f4891f6aa2f76459880ace389c9 Reviewed-on: https://go-review.googlesource.com/c/tools/+/402034 Reviewed-by: Dominik Honnef Reviewed-by: Daniel Martí Reviewed-by: Tim King Reviewed-by: Zvonimir Pavlinovic --- go/ssa/func.go | 7 ++++--- go/ssa/ssa.go | 14 +++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/go/ssa/func.go b/go/ssa/func.go index c864b495e7..9ce2bfe410 100644 --- a/go/ssa/func.go +++ b/go/ssa/func.go @@ -74,13 +74,14 @@ type lblock struct { // labelledBlock returns the branch target associated with the // specified label, creating it if needed. func (f *Function) labelledBlock(label *ast.Ident) *lblock { - lb := f.lblocks[label.Obj] + obj := f.objectOf(label) + lb := f.lblocks[obj] if lb == nil { lb = &lblock{_goto: f.newBasicBlock(label.Name)} if f.lblocks == nil { - f.lblocks = make(map[*ast.Object]*lblock) + f.lblocks = make(map[types.Object]*lblock) } - f.lblocks[label.Obj] = lb + f.lblocks[obj] = lb } return lb } diff --git a/go/ssa/ssa.go b/go/ssa/ssa.go index 0b252531fb..c96ced2265 100644 --- a/go/ssa/ssa.go +++ b/go/ssa/ssa.go @@ -331,13 +331,13 @@ type Function struct { // The following fields are set transiently during building, // then cleared. - currentBlock *BasicBlock // where to emit code - objects map[types.Object]Value // addresses of local variables - namedResults []*Alloc // tuple of named results - targets *targets // linked stack of branch targets - lblocks map[*ast.Object]*lblock // labelled blocks - info *types.Info // *types.Info to build from. nil for wrappers. - subst *subster // type substitution cache + currentBlock *BasicBlock // where to emit code + objects map[types.Object]Value // addresses of local variables + namedResults []*Alloc // tuple of named results + targets *targets // linked stack of branch targets + lblocks map[types.Object]*lblock // labelled blocks + info *types.Info // *types.Info to build from. nil for wrappers. + subst *subster // type substitution cache } // BasicBlock represents an SSA basic block.