]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.ssa] cmd/compile: everything is live and reachable after regalloc
authorJosh Bleecher Snyder <josharian@gmail.com>
Fri, 21 Aug 2015 17:15:15 +0000 (10:15 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Fri, 21 Aug 2015 20:00:51 +0000 (20:00 +0000)
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>
src/cmd/compile/internal/ssa/deadcode.go

index 8c306c8412e5b1b80f50ba768a040423c2c185ea..5ff082baff13ce694e74528b35925914fc69394e 100644 (file)
@@ -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