aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/debug.go
diff options
context:
space:
mode:
authorDavid Chase <drchase@google.com>2017-10-27 17:02:11 -0400
committerDavid Chase <drchase@google.com>2017-11-05 18:32:53 +0000
commitd58d90152ba172dfa52d3135f5fea9b57927e230 (patch)
tree56326a814b5bfbfe35c0bef8f895d625e8c2154d /src/cmd/compile/internal/ssa/debug.go
parent38c725b14830bc1a95eb48cfb04d5f4c6d916a28 (diff)
downloadgo-d58d90152ba172dfa52d3135f5fea9b57927e230.tar.gz
go-d58d90152ba172dfa52d3135f5fea9b57927e230.zip
cmd/compile: adjust locationlist lifetimes
A statement like foo = bar + qux might compile to AX := AX + BX resulting in a regkill for AX before this instruction. The buggy behavior is to kill AX "at" this instruction, before it has executed. (Code generation of no-instruction values like RegKills applies their effects at the next actual instruction emitted). However, bar is still associated with AX until after the instruction executes, so the effect of the regkill must occur at the boundary between this instruction and the next. Similarly, the new value bound to AX is not visible until this instruction executes (and in the case of values that require multiple instructions in code generation, until all of them have executed). The ranges are adjusted so that a value's start occurs at the next following instruction after its evaluation, and the end occurs after (execution of) the first instruction following the end of the lifetime as a value. (Notice the asymmetry; the entire value must be finished before it is visible, but execution of a single instruction invalidates. However, the value *is* visible before that next instruction executes). The test was adjusted to make it insensitive to the result numbering for variables printed by gdb, since that is not relevant to the test and makes the differences introduced by small changes larger than necessary/useful. The test was also improved to present variable probes more intuitively, and also to allow explicit indication of "this variable was optimized out" Change-Id: I39453eead8399e6bb05ebd957289b112d1100c0e Reviewed-on: https://go-review.googlesource.com/74090 Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/debug.go')
-rw-r--r--src/cmd/compile/internal/ssa/debug.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/ssa/debug.go b/src/cmd/compile/internal/ssa/debug.go
index 60c914d778..dcef9f2447 100644
--- a/src/cmd/compile/internal/ssa/debug.go
+++ b/src/cmd/compile/internal/ssa/debug.go
@@ -290,6 +290,8 @@ func BuildFuncDebug(f *Func, loggingEnabled bool) *FuncDebug {
state.logf("Processing %v, initial locs %v, regs %v\n", b, state.BlockString(locs), state.registerContents)
}
// Update locs/registers with the effects of each Value.
+ // The location list generated here needs to be slightly adjusted for use by gdb.
+ // These adjustments are applied in genssa.
for _, v := range b.Values {
slots := valueNames[v.ID]
@@ -323,7 +325,6 @@ func BuildFuncDebug(f *Func, loggingEnabled bool) *FuncDebug {
reg, _ := f.getHome(v.ID).(*Register)
state.processValue(locs, v, slots, reg)
-
}
// The block is done; mark any live locations as ending with the block.
@@ -449,7 +450,8 @@ func (state *debugState) mergePredecessors(b *Block, blockLocs []*BlockDebug) *B
}
// processValue updates locs and state.registerContents to reflect v, a value with
-// the names in vSlots and homed in vReg.
+// the names in vSlots and homed in vReg. "v" becomes visible after execution of
+// the instructions evaluating it.
func (state *debugState) processValue(locs *BlockDebug, v *Value, vSlots []SlotID, vReg *Register) {
switch {
case v.Op == OpRegKill:
@@ -531,7 +533,6 @@ func (state *debugState) processValue(locs *BlockDebug, v *Value, vSlots []SlotI
if state.loggingEnabled {
state.logf("at %v: %v spilled to stack location %v\n", v.ID, state.slots[slot], state.slots[loc.StackLocation])
}
-
}
case vReg != nil: