diff options
| author | Matthew Dempsky <mdempsky@google.com> | 2017-03-21 10:15:14 -0700 |
|---|---|---|
| committer | Matthew Dempsky <mdempsky@google.com> | 2017-03-21 17:46:25 +0000 |
| commit | baa0fdd0934cb9dca88ea0effb46cf42089c9ccd (patch) | |
| tree | baf1ffebc8d1de629ef0e7544425b86452f196b2 /src | |
| parent | 2e29eb57dbd2bc7b022fadc33943b0a5ee69324d (diff) | |
| download | go-baa0fdd0934cb9dca88ea0effb46cf42089c9ccd.tar.xz | |
cmd/compile/internal/gc: fix liveness regression
During AllocFrame, we drop unused variables from Curfn.Func.Dcl, but
there might still be OpVarFoo instructions that reference those
variables. This wasn't a problem though because gvardefx used to emit
ANOP for unused variables instead of AVARFOO.
As an easy fix, if we see OpVarFoo (or OpKeepAlive) referencing an
unused variable, we can ignore it.
Fixes #19632.
Change-Id: I4e9ffabdb4058f7cdcc4663b540f5a5a692daf8b
Reviewed-on: https://go-review.googlesource.com/38400
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/compile/internal/gc/plive.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/gc/plive.go b/src/cmd/compile/internal/gc/plive.go index b3cecdf894..8b8882ac55 100644 --- a/src/cmd/compile/internal/gc/plive.go +++ b/src/cmd/compile/internal/gc/plive.go @@ -186,6 +186,17 @@ func (lv *Liveness) valueEffects(v *ssa.Value) (pos int32, effect liveEffect) { return -1, 0 } + // AllocFrame has dropped unused variables from + // lv.fn.Func.Dcl, but they might still be referenced by + // OpVarFoo pseudo-ops. Ignore them to prevent "lost track of + // variable" ICEs (issue 19632). + switch v.Op { + case ssa.OpVarDef, ssa.OpVarKill, ssa.OpVarLive, ssa.OpKeepAlive: + if !n.Used() { + return -1, 0 + } + } + pos = liveIndex(n, lv.vars) if pos < 0 { return -1, 0 |
