Commit ff262913 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: seed rand with time when race enabled

When the race detector is enabled,
the compiler randomizes the order in which functions are compiled,
in an attempt to shake out bugs.
But we never re-seed the rand source, so every execution is identical.
Fix that to get more coverage.

Change-Id: If5cdde03ef4f1bab5f45e07f03fb6614945481d7
Reviewed-on: https://go-review.googlesource.com/43572
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 7555a45d
...@@ -16,6 +16,7 @@ import ( ...@@ -16,6 +16,7 @@ import (
"math/rand" "math/rand"
"sort" "sort"
"sync" "sync"
"time"
) )
// "Portable" code generation. // "Portable" code generation.
...@@ -249,6 +250,12 @@ func compileSSA(fn *Node, worker int) { ...@@ -249,6 +250,12 @@ func compileSSA(fn *Node, worker int) {
pp.Free() pp.Free()
} }
func init() {
if raceEnabled {
rand.Seed(time.Now().UnixNano())
}
}
// compileFunctions compiles all functions in compilequeue. // compileFunctions compiles all functions in compilequeue.
// It fans out nBackendWorkers to do the work // It fans out nBackendWorkers to do the work
// and waits for them to complete. // and waits for them to complete.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment