diff options
author | Heschi Kreinick <heschi@google.com> | 2018-03-13 16:14:52 -0400 |
---|---|---|
committer | David Chase <drchase@google.com> | 2018-03-14 20:52:29 +0000 |
commit | 44e65f2c94bbae463314382fd77ce690c81b413e (patch) | |
tree | 7fc4f552fe4a86637dec51aefb50e17fe73a2b54 /src/cmd/compile/internal/ssa/debug.go | |
parent | aff222cd185d10400b9177fe26ec06eb647b092d (diff) | |
download | go-44e65f2c94bbae463314382fd77ce690c81b413e.tar.gz go-44e65f2c94bbae463314382fd77ce690c81b413e.zip |
cmd/compile/internal/ssa: track stack-only vars
User variables that cannot be SSA'd, either because their addresses are
taken or because they are too large for the decomposition heuristic, do
not explicitly appear as operands of SSA values. Instead they are written
to directly via the stack pointer.
This hid them from the location list generation, which is only
interested in the named value table. Fortunately, the lifetime of
stack-only variables is delineated by VarDef/VarKill ops, and it's easy
enough to turn those into location list bounds.
One wrinkle: stack frame information is not explicitly available in the
SSA phases, because it's owned by the frontend in AllocFrame. It would
be easier if the set of live LocalSlots were returned by that, but this
is the minimal change to fix missing variables. Or VarDef/VarKills
could appear in NamedValues, which would make this change even easier.
Change-Id: Ice6654dad6f9babb0286e95c7ec28594561dc91f
Reviewed-on: https://go-review.googlesource.com/100458
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/debug.go')
-rw-r--r-- | src/cmd/compile/internal/ssa/debug.go | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/ssa/debug.go b/src/cmd/compile/internal/ssa/debug.go index cca4209d7b..036806182c 100644 --- a/src/cmd/compile/internal/ssa/debug.go +++ b/src/cmd/compile/internal/ssa/debug.go @@ -372,6 +372,26 @@ func BuildFuncDebug(ctxt *obj.Link, f *Func, loggingEnabled bool, stackOffset fu state.varParts[topSlot.N] = append(state.varParts[topSlot.N], SlotID(i)) } + // Recreate the LocalSlot for each stack-only variable. + // This would probably be better as an output from stackframe. + for _, b := range f.Blocks { + for _, v := range b.Values { + if v.Op == OpVarDef || v.Op == OpVarKill { + n := v.Aux.(GCNode) + if n.IsSynthetic() { + continue + } + + if _, ok := state.varParts[n]; !ok { + slot := LocalSlot{N: n, Type: v.Type, Off: 0} + state.slots = append(state.slots, slot) + state.varParts[n] = []SlotID{SlotID(len(state.slots) - 1)} + state.vars = append(state.vars, n) + } + } + } + } + // Fill in the var<->slot mappings. if cap(state.varSlots) < len(state.vars) { state.varSlots = make([][]SlotID, len(state.vars)) @@ -644,6 +664,26 @@ func (state *debugState) processValue(v *Value, vSlots []SlotID, vReg *Register) } switch { + case v.Op == OpVarDef, v.Op == OpVarKill: + n := v.Aux.(GCNode) + if n.IsSynthetic() { + break + } + + slotID := state.varParts[n][0] + var stackOffset StackOffset + if v.Op == OpVarDef { + stackOffset = StackOffset(state.stackOffset(state.slots[slotID])<<1 | 1) + } + setSlot(slotID, VarLoc{0, stackOffset}) + if state.loggingEnabled { + if v.Op == OpVarDef { + state.logf("at %v: stack-only var %v now live\n", v.ID, state.slots[slotID]) + } else { + state.logf("at %v: stack-only var %v now dead\n", v.ID, state.slots[slotID]) + } + } + case v.Op == OpArg: home := state.f.getHome(v.ID).(LocalSlot) stackOffset := state.stackOffset(home)<<1 | 1 @@ -825,7 +865,7 @@ func (state *debugState) buildLocationLists(blockLocs []*BlockDebug) { state.writePendingEntry(VarID(varID), state.f.Blocks[len(state.f.Blocks)-1].ID, BlockEnd.ID) list := state.lists[varID] if len(list) == 0 { - continue + state.logf("\t%v : empty list\n", state.vars[varID]) } if state.loggingEnabled { |