From 9f743cf3a52d54c11b36769e881ccf7790e22de3 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Thu, 11 May 2017 11:42:44 -0700 Subject: [PATCH] Always create live ranges for dead EBB arguments. The live value tracker expects them to be there. We may eventually delete dead arguments from internal EBBs, but at least the entry block needs to be able to handle dead function arguments. --- filetests/regalloc/basic.cton | 7 +++++++ lib/cretonne/src/regalloc/liveness.rs | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/filetests/regalloc/basic.cton b/filetests/regalloc/basic.cton index 14fa263ac0..9db7b7563a 100644 --- a/filetests/regalloc/basic.cton +++ b/filetests/regalloc/basic.cton @@ -10,3 +10,10 @@ ebb0(v1: i32, v2: i32): ; sameln: iadd return } + +; Function with a dead argument. +function dead_arg(i32, i32) -> i32{ +ebb0(v1: i32, v2: i32): +; check: return $v1 + return v1 +} diff --git a/lib/cretonne/src/regalloc/liveness.rs b/lib/cretonne/src/regalloc/liveness.rs index 737470b2d1..f2c9944d4b 100644 --- a/lib/cretonne/src/regalloc/liveness.rs +++ b/lib/cretonne/src/regalloc/liveness.rs @@ -311,6 +311,13 @@ impl Liveness { // elimination pass if we visit a post-order of the dominator tree? // TODO: Resolve value aliases while we're visiting instructions? for ebb in func.layout.ebbs() { + // Make sure we have created live ranges for dead EBB arguments. + // TODO: If these arguments are really dead, we could remove them, except for the entry + // block which must match the function signature. + for &arg in func.dfg.ebb_args(ebb) { + get_or_create(&mut self.ranges, arg, isa, func, &enc_info); + } + 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