mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: make compilation deterministic, fixes toolstash
Make sure we don't depend on map iterator order. Fixes #14600 Change-Id: Iac0e0c8689f3ace7a4dc8e2127e2fd3c8545bd29 Reviewed-on: https://go-review.googlesource.com/20158 Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
c03ed491fe
commit
686fbdb3b0
2 changed files with 16 additions and 8 deletions
|
|
@ -143,7 +143,7 @@ func fprintFunc(p funcPrinter, f *Func) {
|
||||||
|
|
||||||
p.endBlock(b)
|
p.endBlock(b)
|
||||||
}
|
}
|
||||||
for name, vals := range f.NamedValues {
|
for _, name := range f.Names {
|
||||||
p.named(name, vals)
|
p.named(name, f.NamedValues[name])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1161,7 +1161,8 @@ type edgeState struct {
|
||||||
p, b *Block // edge goes from p->b.
|
p, b *Block // edge goes from p->b.
|
||||||
|
|
||||||
// for each pre-regalloc value, a list of equivalent cached values
|
// for each pre-regalloc value, a list of equivalent cached values
|
||||||
cache map[ID][]*Value
|
cache map[ID][]*Value
|
||||||
|
cachedVals []ID // (superset of) keys of the above map, for deterministic iteration
|
||||||
|
|
||||||
// map from location to the value it contains
|
// map from location to the value it contains
|
||||||
contents map[Location]contentRecord
|
contents map[Location]contentRecord
|
||||||
|
|
@ -1194,9 +1195,10 @@ func (e *edgeState) setup(idx int, srcReg []endReg, dstReg []startReg, stacklive
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear state.
|
// Clear state.
|
||||||
for k := range e.cache {
|
for _, vid := range e.cachedVals {
|
||||||
delete(e.cache, k)
|
delete(e.cache, vid)
|
||||||
}
|
}
|
||||||
|
e.cachedVals = e.cachedVals[:0]
|
||||||
for k := range e.contents {
|
for k := range e.contents {
|
||||||
delete(e.contents, k)
|
delete(e.contents, k)
|
||||||
}
|
}
|
||||||
|
|
@ -1234,7 +1236,8 @@ func (e *edgeState) setup(idx int, srcReg []endReg, dstReg []startReg, stacklive
|
||||||
e.destinations = dsts
|
e.destinations = dsts
|
||||||
|
|
||||||
if regDebug {
|
if regDebug {
|
||||||
for vid, a := range e.cache {
|
for _, vid := range e.cachedVals {
|
||||||
|
a := e.cache[vid]
|
||||||
for _, c := range a {
|
for _, c := range a {
|
||||||
fmt.Printf("src %s: v%d cache=%s\n", e.s.f.getHome(c.ID).Name(), vid, c)
|
fmt.Printf("src %s: v%d cache=%s\n", e.s.f.getHome(c.ID).Name(), vid, c)
|
||||||
}
|
}
|
||||||
|
|
@ -1423,6 +1426,9 @@ func (e *edgeState) set(loc Location, vid ID, c *Value, final bool) {
|
||||||
e.erase(loc)
|
e.erase(loc)
|
||||||
e.contents[loc] = contentRecord{vid, c, final}
|
e.contents[loc] = contentRecord{vid, c, final}
|
||||||
a := e.cache[vid]
|
a := e.cache[vid]
|
||||||
|
if len(a) == 0 {
|
||||||
|
e.cachedVals = append(e.cachedVals, vid)
|
||||||
|
}
|
||||||
a = append(a, c)
|
a = append(a, c)
|
||||||
e.cache[vid] = a
|
e.cache[vid] = a
|
||||||
if r, ok := loc.(*Register); ok {
|
if r, ok := loc.(*Register); ok {
|
||||||
|
|
@ -1522,7 +1528,8 @@ func (e *edgeState) findRegFor(typ Type) Location {
|
||||||
// TODO: reuse these slots.
|
// TODO: reuse these slots.
|
||||||
|
|
||||||
// Pick a register to spill.
|
// Pick a register to spill.
|
||||||
for vid, a := range e.cache {
|
for _, vid := range e.cachedVals {
|
||||||
|
a := e.cache[vid]
|
||||||
for _, c := range a {
|
for _, c := range a {
|
||||||
if r, ok := e.s.f.getHome(c.ID).(*Register); ok && m>>uint(r.Num)&1 != 0 {
|
if r, ok := e.s.f.getHome(c.ID).(*Register); ok && m>>uint(r.Num)&1 != 0 {
|
||||||
x := e.p.NewValue1(c.Line, OpStoreReg, c.Type, c)
|
x := e.p.NewValue1(c.Line, OpStoreReg, c.Type, c)
|
||||||
|
|
@ -1539,7 +1546,8 @@ func (e *edgeState) findRegFor(typ Type) Location {
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("m:%d unique:%d final:%d\n", m, e.uniqueRegs, e.finalRegs)
|
fmt.Printf("m:%d unique:%d final:%d\n", m, e.uniqueRegs, e.finalRegs)
|
||||||
for vid, a := range e.cache {
|
for _, vid := range e.cachedVals {
|
||||||
|
a := e.cache[vid]
|
||||||
for _, c := range a {
|
for _, c := range a {
|
||||||
fmt.Printf("v%d: %s %s\n", vid, c, e.s.f.getHome(c.ID).Name())
|
fmt.Printf("v%d: %s %s\n", vid, c, e.s.f.getHome(c.ID).Name())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue