Skip to content

Commit

Permalink
cmd/compile: use s.temp for creating defer struct
Browse files Browse the repository at this point in the history
Follow discussion in go.dev/cl/521676.

Change-Id: Ie5c0ce66b60fcbfd59385e8c2c45d431133ab53a
Reviewed-on: https://go-review.googlesource.com/c/go/+/522115
Run-TryBot: Cuong Manh Le <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
Auto-Submit: Cuong Manh Le <[email protected]>
Reviewed-by: Matthew Dempsky <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
  • Loading branch information
cuonglm authored and gopherbot committed Aug 23, 2023
1 parent 079dfdc commit 86f0f08
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/cmd/compile/internal/ssagen/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -5249,19 +5249,12 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val

var call *ssa.Value
if k == callDeferStack {
// Make a defer struct d on the stack.
if stksize != 0 {
s.Fatalf("deferprocStack with non-zero stack size %d: %v", stksize, n)
}

// Make a defer struct on the stack.
t := deferstruct()
d := typecheck.TempAt(n.Pos(), s.curfn, t)

if t.HasPointers() {
s.vars[memVar] = s.newValue1A(ssa.OpVarDef, types.TypeMem, d, s.mem())
}
addr := s.addr(d)

_, addr := s.temp(n.Pos(), t)
s.store(closure.Type,
s.newValue1I(ssa.OpOffPtr, closure.Type.PtrTo(), t.FieldOff(deferStructFnField), addr),
closure)
Expand Down

0 comments on commit 86f0f08

Please sign in to comment.