aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/flagalloc.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2016-09-16 13:50:18 -0700
committerKeith Randall <khr@golang.org>2016-09-19 16:00:13 +0000
commit75ce89c20dab10857ab0b5102001b34767c45b6e (patch)
treeb6d0086e53b0187137ca606d54e10d799d7f2761 /src/cmd/compile/internal/ssa/flagalloc.go
parent2679282da4e437ee086ec791ab73181c39ae3463 (diff)
downloadgo-75ce89c20dab10857ab0b5102001b34767c45b6e.tar.gz
go-75ce89c20dab10857ab0b5102001b34767c45b6e.zip
cmd/compile: cache CFG-dependent computations
We compute a lot of stuff based off the CFG: postorder traversal, dominators, dominator tree, loop nest. Multiple phases use this information and we end up recomputing some of it. Add a cache for this information so if the CFG hasn't changed, we can reuse the previous computation. Change-Id: I9b5b58af06830bd120afbee9cfab395a0a2f74b2 Reviewed-on: https://go-review.googlesource.com/29356 Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/flagalloc.go')
-rw-r--r--src/cmd/compile/internal/ssa/flagalloc.go8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/cmd/compile/internal/ssa/flagalloc.go b/src/cmd/compile/internal/ssa/flagalloc.go
index 5d1ced42b4..24b6a0ec89 100644
--- a/src/cmd/compile/internal/ssa/flagalloc.go
+++ b/src/cmd/compile/internal/ssa/flagalloc.go
@@ -11,14 +11,10 @@ func flagalloc(f *Func) {
// Compute the in-register flag value we want at the end of
// each block. This is basically a best-effort live variable
// analysis, so it can be much simpler than a full analysis.
- // TODO: do we really need to keep flag values live across blocks?
- // Could we force the flags register to be unused at basic block
- // boundaries? Then we wouldn't need this computation.
end := make([]*Value, f.NumBlocks())
+ po := f.postorder()
for n := 0; n < 2; n++ {
- // Walk blocks backwards. Poor-man's postorder traversal.
- for i := len(f.Blocks) - 1; i >= 0; i-- {
- b := f.Blocks[i]
+ for _, b := range po {
// Walk values backwards to figure out what flag
// value we want in the flag register at the start
// of the block.