aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssagen/ssa.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/compile/internal/ssagen/ssa.go')
-rw-r--r--src/cmd/compile/internal/ssagen/ssa.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssagen/ssa.go b/src/cmd/compile/internal/ssagen/ssa.go
index 1cbe414865..2ffd49198a 100644
--- a/src/cmd/compile/internal/ssagen/ssa.go
+++ b/src/cmd/compile/internal/ssagen/ssa.go
@@ -5118,6 +5118,18 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val
for _, p := range params.InParams() { // includes receiver for interface calls
ACArgs = append(ACArgs, p.Type)
}
+
+ // Split the entry block if there are open defers, because later calls to
+ // openDeferSave may cause a mismatch between the mem for an OpDereference
+ // and the call site which uses it. See #49282.
+ if s.curBlock.ID == s.f.Entry.ID && s.hasOpenDefers {
+ b := s.endBlock()
+ b.Kind = ssa.BlockPlain
+ curb := s.f.NewBlock(ssa.BlockPlain)
+ b.AddEdgeTo(curb)
+ s.startBlock(curb)
+ }
+
for i, n := range args {
callArgs = append(callArgs, s.putArg(n, t.Params().Field(i).Type))
}