Skip to content

Commit 3c16934

Browse files
committed
cmd/compile: fix failure to reset reused bit of storage
This is the "3rd bug" that caused compilations to sometimes produce different results when dwarf location lists were enabled. A loop had not been properly rewritten in an earlier optimization CL, and it accessed uninitialized data, which was deterministically perhaps wrong when single threaded, but variably wrong when multithreaded. Change-Id: Ib3da538762fdf7d5e4407106f2434f3b14a1d7ea Reviewed-on: https://go-review.googlesource.com/99935 Run-TryBot: David Chase <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]>
1 parent 867d07f commit 3c16934

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/cmd/compile/internal/ssa/debug.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -578,12 +578,12 @@ func (state *debugState) mergePredecessors(b *Block, blockLocs []*BlockDebug) ([
578578

579579
// A slot is live if it was seen in all predecessors, and they all had
580580
// some storage in common.
581-
for slotID := range p0 {
582-
slotLoc := slotLocs[slotID]
581+
for _, predSlot := range p0 {
582+
slotLoc := slotLocs[predSlot.slot]
583583

584-
if state.liveCount[slotID] != len(preds) {
584+
if state.liveCount[predSlot.slot] != len(preds) {
585585
// Seen in only some predecessors. Clear it out.
586-
slotLocs[slotID] = VarLoc{}
586+
slotLocs[predSlot.slot] = VarLoc{}
587587
continue
588588
}
589589

@@ -596,7 +596,7 @@ func (state *debugState) mergePredecessors(b *Block, blockLocs []*BlockDebug) ([
596596
reg := uint8(TrailingZeros64(mask))
597597
mask &^= 1 << reg
598598

599-
state.currentState.registers[reg] = append(state.currentState.registers[reg], SlotID(slotID))
599+
state.currentState.registers[reg] = append(state.currentState.registers[reg], predSlot.slot)
600600
}
601601
}
602602
return nil, false

0 commit comments

Comments
 (0)