mirror of
https://github.com/golang/go
synced 2024-11-23 00:10:07 -07:00
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>
This commit is contained in:
parent
aff222cd18
commit
44e65f2c94
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user