From 7393c24877407ff2d3d1fad761e5aebbf6671ac3 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Fri, 21 Aug 2015 10:15:15 -0700 Subject: [PATCH] [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 --- src/cmd/compile/internal/ssa/deadcode.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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