mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: keep heap pointer for escaping output parameters live
Make sure the pointer to the heap copy of an output parameter is kept live throughout the function. The function could panic at any point, and then a defer could recover. Thus, we need the pointer to the heap copy always available so the post-deferreturn code can copy the return value back to the stack. Before this CL, the pointer to the heap copy could be considered dead in certain situations, like code which is reverse dominated by a panic call. Fixes #16095. Change-Id: Ic3800423e563670e5b567b473bf4c84cddb49a4c Reviewed-on: https://go-review.googlesource.com/24213 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
parent
e96b1ef99b
commit
6effdd28de
4 changed files with 136 additions and 0 deletions
|
|
@ -79,6 +79,7 @@ const (
|
|||
hasBreak = 1 << iota
|
||||
notLiveAtEnd
|
||||
isClosureVar
|
||||
isOutputParamHeapAddr
|
||||
)
|
||||
|
||||
func (n *Node) HasBreak() bool {
|
||||
|
|
@ -112,6 +113,17 @@ func (n *Node) setIsClosureVar(b bool) {
|
|||
}
|
||||
}
|
||||
|
||||
func (n *Node) IsOutputParamHeapAddr() bool {
|
||||
return n.flags&isOutputParamHeapAddr != 0
|
||||
}
|
||||
func (n *Node) setIsOutputParamHeapAddr(b bool) {
|
||||
if b {
|
||||
n.flags |= isOutputParamHeapAddr
|
||||
} else {
|
||||
n.flags &^= isOutputParamHeapAddr
|
||||
}
|
||||
}
|
||||
|
||||
// Val returns the Val for the node.
|
||||
func (n *Node) Val() Val {
|
||||
if n.hasVal != +1 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue