From 74eb13c17a6e648b58117ff6188674f2a0e85764 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Sat, 18 Feb 2017 10:22:27 -0800 Subject: [PATCH] Create live ranges for dead defs. When the liveness pass implements dead code elimination, missing live ranges can be used to indicate unused values that it may be possible to remove. But even then, we may have to keep dead defs around if the instruction has side effects or other live defs. --- lib/cretonne/src/regalloc/liveness.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/cretonne/src/regalloc/liveness.rs b/lib/cretonne/src/regalloc/liveness.rs index da4b2568f9..a8591e8597 100644 --- a/lib/cretonne/src/regalloc/liveness.rs +++ b/lib/cretonne/src/regalloc/liveness.rs @@ -304,6 +304,13 @@ impl Liveness { // TODO: Resolve value aliases while we're visiting instructions? for ebb in func.layout.ebbs() { for inst in func.layout.ebb_insts(ebb) { + // Make sure we have created live ranges for dead defs. + // TODO: When we implement DCE, we can use the absence of a live range to indicate + // an unused value. + for def in func.dfg.inst_results(inst) { + get_or_create(&mut self.ranges, def, func, recipe_constraints); + } + // The instruction encoding is used to compute affinities. let recipe = func.encodings[inst].recipe(); // Iterator of constraints, one per value operand.