From: Andy Ayers Date: Thu, 16 Aug 2018 00:05:28 +0000 (-0700) Subject: JIT: properly handle special-case varargs params in minopts (dotnet/coreclr#19489) X-Git-Tag: submit/tizen/20210909.063632~11030^2~4134 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=45a8740151dbb71e04d169ffc3af59f59cf9b3c5;p=platform%2Fupstream%2Fdotnet%2Fruntime.git JIT: properly handle special-case varargs params in minopts (dotnet/coreclr#19489) We were previously marking all lcl vars as implicitly referenced in minopts, but there are some special varargs params that can't ever be marked as referenced, either implicitly or explicitly. Special case these when computing or checking ref counts in minopts. Closes dotnet/coreclr#19349. Commit migrated from https://github.com/dotnet/coreclr/commit/81c0e509c0e948385268e209db0696f2bbddd575 --- diff --git a/src/coreclr/src/jit/lclvars.cpp b/src/coreclr/src/jit/lclvars.cpp index 70b6eee..324896b 100644 --- a/src/coreclr/src/jit/lclvars.cpp +++ b/src/coreclr/src/jit/lclvars.cpp @@ -4100,7 +4100,16 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers) // to do something else to ensure late temps are considered. for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++) { - assert(varDsc->lvImplicitlyReferenced); + const bool isSpecialVarargsParam = varDsc->lvIsParam && raIsVarargsStackArg(lclNum); + + if (isSpecialVarargsParam) + { + assert(varDsc->lvRefCnt() == 0); + } + else + { + assert(varDsc->lvImplicitlyReferenced); + } } #endif // defined (DEBUG) @@ -4118,8 +4127,17 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers) // unreferenced later, we'll have to explicitly clear this bit. varDsc->setLvRefCnt(0); varDsc->setLvRefCntWtd(0); - varDsc->lvImplicitlyReferenced = 1; - varDsc->lvTracked = 0; + + // Special case for some varargs params ... these must + // remain unreferenced. + const bool isSpecialVarargsParam = varDsc->lvIsParam && raIsVarargsStackArg(lclNum); + + if (!isSpecialVarargsParam) + { + varDsc->lvImplicitlyReferenced = 1; + } + + varDsc->lvTracked = 0; if (setSlotNumbers) {