]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: fix failure to reset reused bit of storage
authorDavid Chase <drchase@google.com>
Fri, 9 Mar 2018 22:33:29 +0000 (17:33 -0500)
committerDavid Chase <drchase@google.com>
Tue, 13 Mar 2018 05:03:31 +0000 (05:03 +0000)
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 <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
src/cmd/compile/internal/ssa/debug.go

index 1e03ce296488b782cffbf7c133ac1c0079aee781..cca4209d7b09a971bfcc0cafd92a41a9e11ab007 100644 (file)
@@ -578,12 +578,12 @@ func (state *debugState) mergePredecessors(b *Block, blockLocs []*BlockDebug) ([
 
        // A slot is live if it was seen in all predecessors, and they all had
        // some storage in common.
-       for slotID := range p0 {
-               slotLoc := slotLocs[slotID]
+       for _, predSlot := range p0 {
+               slotLoc := slotLocs[predSlot.slot]
 
-               if state.liveCount[slotID] != len(preds) {
+               if state.liveCount[predSlot.slot] != len(preds) {
                        // Seen in only some predecessors. Clear it out.
-                       slotLocs[slotID] = VarLoc{}
+                       slotLocs[predSlot.slot] = VarLoc{}
                        continue
                }
 
@@ -596,7 +596,7 @@ func (state *debugState) mergePredecessors(b *Block, blockLocs []*BlockDebug) ([
                        reg := uint8(TrailingZeros64(mask))
                        mask &^= 1 << reg
 
-                       state.currentState.registers[reg] = append(state.currentState.registers[reg], SlotID(slotID))
+                       state.currentState.registers[reg] = append(state.currentState.registers[reg], predSlot.slot)
                }
        }
        return nil, false