From 0c5f3d4b76e0ac8e70d555080ba7e49d08121536 Mon Sep 17 00:00:00 2001 From: Carol Eidt Date: Fri, 9 Mar 2018 17:50:29 -0800 Subject: Fix LSRA enregisterLocalVars We don't bother with the parts of LSRA that deal with lclVars if we have no tracked lclVars. However, we need to check that *after* liveness has run post-Lowering - otherwise we miss any lclVars created by optimizations or during Lowering. Fix #16578 --- src/jit/lsra.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/jit/lsra.cpp b/src/jit/lsra.cpp index 5687db92c1..6727599e48 100644 --- a/src/jit/lsra.cpp +++ b/src/jit/lsra.cpp @@ -708,7 +708,12 @@ LinearScan::LinearScan(Compiler* theCompiler) #endif // 0 #endif // DEBUG - enregisterLocalVars = ((compiler->opts.compFlags & CLFLG_REGVAR) != 0) && compiler->lvaTrackedCount > 0; + // Assume that we will enregister local variables if it's not disabled. We'll reset it if we + // have no tracked locals when we start allocating. Note that new tracked lclVars may be added + // after the first liveness analysis - either by optimizations or by Lowering, and the tracked + // set won't be recomputed until after Lowering (and this constructor is called prior to Lowering), + // so we don't want to check that yet. + enregisterLocalVars = ((compiler->opts.compFlags & CLFLG_REGVAR) != 0); #ifdef _TARGET_ARM64_ availableIntRegs = (RBM_ALLINT & ~(RBM_PR | RBM_FP | RBM_LR) & ~compiler->codeGen->regSet.rsMaskResvd); #else @@ -1308,6 +1313,15 @@ BasicBlock* LinearScan::getNextBlock() void LinearScan::doLinearScan() { + // Check to see whether we have any local variables to enregister. + // We initialize this in the constructor based on opt settings, + // but we don't want to spend time on the lclVar parts of LinearScan + // if we have no tracked locals. + if (enregisterLocalVars && (compiler->lvaTrackedCount == 0)) + { + enregisterLocalVars = false; + } + unsigned lsraBlockEpoch = compiler->GetCurBasicBlockEpoch(); splitBBNumToTargetBBNumMap = nullptr; -- cgit v1.2.3