From bca4b339b1d3a649219d111149d401e50b4279a7 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Wed, 8 Aug 2018 00:28:02 -0700 Subject: [PATCH] JIT: update lvaGrabTemp for new minopts/debug ref counting approach If the jit has started normal ref counting and is in minopts or debug, set all new temps to be implicitly referenced by default. Closes #19346. --- src/jit/compiler.hpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/jit/compiler.hpp b/src/jit/compiler.hpp index 545f311ab35e..c1b050cc4f00 100644 --- a/src/jit/compiler.hpp +++ b/src/jit/compiler.hpp @@ -1682,13 +1682,22 @@ inline unsigned Compiler::lvaGrabTemp(bool shortLifetime DEBUGARG(const char* re lvaTable = newLvaTable; } - lvaTable[lvaCount].lvType = TYP_UNDEF; // Initialize lvType, lvIsTemp and lvOnFrame - lvaTable[lvaCount].lvIsTemp = shortLifetime; - lvaTable[lvaCount].lvOnFrame = true; + const unsigned tempNum = lvaCount; + lvaCount++; - unsigned tempNum = lvaCount; + lvaTable[tempNum].lvType = TYP_UNDEF; // Initialize lvType, lvIsTemp and lvOnFrame + lvaTable[tempNum].lvIsTemp = shortLifetime; + lvaTable[tempNum].lvOnFrame = true; - lvaCount++; + // If we've started normal ref counting and are in minopts or debug + // mark this variable as implictly referenced. + if (lvaLocalVarRefCounted()) + { + if (opts.MinOpts() || opts.compDbgCode) + { + lvaTable[tempNum].lvImplicitlyReferenced = 1; + } + } #ifdef DEBUG if (verbose)