diff options
author | Dan Scales <danscales@google.com> | 2019-11-01 14:04:08 -0700 |
---|---|---|
committer | Dan Scales <danscales@google.com> | 2019-11-05 17:19:16 +0000 |
commit | 1b3a1db19fc68591198149540f7b3c99f56691da (patch) | |
tree | c7829cb7cc4d46c253a346b39cf6910b17815038 /src/cmd/compile/internal/ssa/likelyadjust.go | |
parent | 414c1d454e6d388443239209220fe0783d4dac71 (diff) | |
download | go-1b3a1db19fc68591198149540f7b3c99f56691da.tar.gz go-1b3a1db19fc68591198149540f7b3c99f56691da.zip |
cmd/compile: fix liveness for open-coded defer args for infinite loops
Once defined, a stack slot holding an open-coded defer arg should always be marked
live, since it may be used at any time if there is a panic. These stack slots are
typically kept live naturally by the open-defer code inlined at each return/exit point.
However, we need to do extra work to make sure that they are kept live if a
function has an infinite loop or a panic exit.
For this fix, only in the case of a function that is using open-coded defers, we
compute the set of blocks (most often empty) that cannot reach a return or a
BlockExit (panic) because of an infinite loop. Then, for each block b which
cannot reach a return or BlockExit or is a BlockExit block, we mark each defer arg
slot as live, as long as the definition of the defer arg slot dominates block b.
For this change, had to export (*Func).sdom (-> Sdom) and SparseTree.isAncestorEq
(-> IsAncestorEq)
Updates #35277
Change-Id: I7b53c9bd38ba384a3794386dd0eb94e4cbde4eb1
Reviewed-on: https://go-review.googlesource.com/c/go/+/204802
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/likelyadjust.go')
-rw-r--r-- | src/cmd/compile/internal/ssa/likelyadjust.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/ssa/likelyadjust.go b/src/cmd/compile/internal/ssa/likelyadjust.go index 012dd77868..49898a1322 100644 --- a/src/cmd/compile/internal/ssa/likelyadjust.go +++ b/src/cmd/compile/internal/ssa/likelyadjust.go @@ -266,14 +266,14 @@ func (l *loop) isWithinOrEq(ll *loop) bool { // we're relying on loop nests to not be terribly deep. func (l *loop) nearestOuterLoop(sdom SparseTree, b *Block) *loop { var o *loop - for o = l.outer; o != nil && !sdom.isAncestorEq(o.header, b); o = o.outer { + for o = l.outer; o != nil && !sdom.IsAncestorEq(o.header, b); o = o.outer { } return o } func loopnestfor(f *Func) *loopnest { po := f.postorder() - sdom := f.sdom() + sdom := f.Sdom() b2l := make([]*loop, f.NumBlocks()) loops := make([]*loop, 0) visited := make([]bool, f.NumBlocks()) @@ -305,7 +305,7 @@ func loopnestfor(f *Func) *loopnest { bb := e.b l := b2l[bb.ID] - if sdom.isAncestorEq(bb, b) { // Found a loop header + if sdom.IsAncestorEq(bb, b) { // Found a loop header if f.pass != nil && f.pass.debug > 4 { fmt.Printf("loop finding succ %s of %s is header\n", bb.String(), b.String()) } @@ -324,7 +324,7 @@ func loopnestfor(f *Func) *loopnest { // Perhaps a loop header is inherited. // is there any loop containing our successor whose // header dominates b? - if !sdom.isAncestorEq(l.header, b) { + if !sdom.IsAncestorEq(l.header, b) { l = l.nearestOuterLoop(sdom, b) } if f.pass != nil && f.pass.debug > 4 { |