aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/deadcode.go
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2015-08-21 10:15:15 -0700
committerJosh Bleecher Snyder <josharian@gmail.com>2015-08-21 20:00:51 +0000
commit7393c24877407ff2d3d1fad761e5aebbf6671ac3 (patch)
treef9875796e50bee8d69ed1e49ae5f8a06e914c845 /src/cmd/compile/internal/ssa/deadcode.go
parent8f51ae8ba5acbd4e91bd7c1c59b375513c395a22 (diff)
downloadgo-7393c24877407ff2d3d1fad761e5aebbf6671ac3.tar.gz
go-7393c24877407ff2d3d1fad761e5aebbf6671ac3.zip
[dev.ssa] cmd/compile: everything is live and reachable after regalloc
This CL makes function printing and HTML generation accurate after regalloc. Prior to this CL, text and HTML function outputs showed live values and blocks as dead. Change-Id: I70669cd8641af841447fc5d2ecbd754b281356f0 Reviewed-on: https://go-review.googlesource.com/13812 Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/deadcode.go')
-rw-r--r--src/cmd/compile/internal/ssa/deadcode.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/deadcode.go b/src/cmd/compile/internal/ssa/deadcode.go
index 8c306c8412..5ff082baff 100644
--- a/src/cmd/compile/internal/ssa/deadcode.go
+++ b/src/cmd/compile/internal/ssa/deadcode.go
@@ -6,6 +6,20 @@ package ssa
// findlive returns the reachable blocks and live values in f.
func findlive(f *Func) (reachable []bool, live []bool) {
+ // After regalloc, consider all blocks and values to be reachable and live.
+ // See the comment at the top of regalloc.go and in deadcode for details.
+ if f.RegAlloc != nil {
+ reachable = make([]bool, f.NumBlocks())
+ for i := range reachable {
+ reachable[i] = true
+ }
+ live = make([]bool, f.NumValues())
+ for i := range live {
+ live[i] = true
+ }
+ return reachable, live
+ }
+
// Find all reachable basic blocks.
reachable = make([]bool, f.NumBlocks())
reachable[f.Entry.ID] = true