diff options
author | Brian Sullivan <briansul@microsoft.com> | 2019-03-14 16:19:07 -0700 |
---|---|---|
committer | Brian Sullivan <briansul@microsoft.com> | 2019-03-14 16:19:07 -0700 |
commit | 6a773c4a849048b65b62940e3c060144cbd31f01 (patch) | |
tree | d37e6ca1d90cdbdc173cc41a91feba8913674477 | |
parent | 07143ef06882a7247972ede9df63dfd1bdfcc941 (diff) | |
download | coreclr-6a773c4a849048b65b62940e3c060144cbd31f01.tar.gz coreclr-6a773c4a849048b65b62940e3c060144cbd31f01.tar.bz2 coreclr-6a773c4a849048b65b62940e3c060144cbd31f01.zip |
Fix for duplicate call to Set when we run out of budget
-rw-r--r-- | src/jit/valuenum.cpp | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/jit/valuenum.cpp b/src/jit/valuenum.cpp index dd4ce0524c..e3063e1079 100644 --- a/src/jit/valuenum.cpp +++ b/src/jit/valuenum.cpp @@ -2381,8 +2381,8 @@ TailCall: { #if FEATURE_VN_TRACE_APPLY_SELECTORS JITDUMP(" AX1: select([" FMT_VN "]store(" FMT_VN ", " FMT_VN ", " FMT_VN "), " FMT_VN - ") ==> " FMT_VN ".\n", - funcApp.m_args[0], arg0VN, funcApp.m_args[1], funcApp.m_args[2], arg1VN, funcApp.m_args[2]); + ") ==> " FMT_VN ".\n", + funcApp.m_args[0], arg0VN, funcApp.m_args[1], funcApp.m_args[2], arg1VN, funcApp.m_args[2]); #endif return funcApp.m_args[2]; } @@ -2393,9 +2393,9 @@ TailCall: assert(funcApp.m_args[1] != arg1VN); // we already checked this above. #if FEATURE_VN_TRACE_APPLY_SELECTORS JITDUMP(" AX2: " FMT_VN " != " FMT_VN " ==> select([" FMT_VN "]store(" FMT_VN ", " FMT_VN - ", " FMT_VN "), " FMT_VN ") ==> select(" FMT_VN ", " FMT_VN ").\n", - arg1VN, funcApp.m_args[1], arg0VN, funcApp.m_args[0], funcApp.m_args[1], funcApp.m_args[2], - arg1VN, funcApp.m_args[0], arg1VN); + ", " FMT_VN "), " FMT_VN ") ==> select(" FMT_VN ", " FMT_VN ").\n", + arg1VN, funcApp.m_args[1], arg0VN, funcApp.m_args[0], funcApp.m_args[1], funcApp.m_args[2], + arg1VN, funcApp.m_args[0], arg1VN); #endif // This is the equivalent of the recursive tail call: // return VNForMapSelect(vnk, typ, funcApp.m_args[0], arg1VN); @@ -2406,19 +2406,19 @@ TailCall: } else if (funcApp.m_func == VNF_PhiDef || funcApp.m_func == VNF_PhiMemoryDef) { - unsigned lclNum = BAD_VAR_NUM; + unsigned lclNum = BAD_VAR_NUM; bool isMemory = false; VNFuncApp phiFuncApp; bool defArgIsFunc = false; if (funcApp.m_func == VNF_PhiDef) { - lclNum = unsigned(funcApp.m_args[0]); + lclNum = unsigned(funcApp.m_args[0]); defArgIsFunc = GetVNFunc(funcApp.m_args[2], &phiFuncApp); } else { assert(funcApp.m_func == VNF_PhiMemoryDef); - isMemory = true; + isMemory = true; defArgIsFunc = GetVNFunc(funcApp.m_args[1], &phiFuncApp); } if (defArgIsFunc && phiFuncApp.m_func == VNF_Phi) @@ -2462,7 +2462,7 @@ TailCall: VNFuncApp phiArgFuncApp; if (GetVNFunc(argRest, &phiArgFuncApp) && phiArgFuncApp.m_func == VNF_Phi) { - cur = phiArgFuncApp.m_args[0]; + cur = phiArgFuncApp.m_args[0]; argRest = phiArgFuncApp.m_args[1]; } else @@ -2525,13 +2525,17 @@ TailCall: } } - // Otherwise, assign a new VN for the function application. - Chunk* c = GetAllocChunk(typ, CEA_Func2); - unsigned offsetWithinChunk = c->AllocVN(); - res = c->m_baseVN + offsetWithinChunk; - reinterpret_cast<VNDefFunc2Arg*>(c->m_defs)[offsetWithinChunk] = fstruct; - GetVNFunc2Map()->Set(fstruct, res); - return res; + // We may have run out of budget and already assigned a result + if (!GetVNFunc2Map()->Lookup(fstruct, &res)) + { + // Otherwise, assign a new VN for the function application. + Chunk* c = GetAllocChunk(typ, CEA_Func2); + unsigned offsetWithinChunk = c->AllocVN(); + res = c->m_baseVN + offsetWithinChunk; + reinterpret_cast<VNDefFunc2Arg*>(c->m_defs)[offsetWithinChunk] = fstruct; + GetVNFunc2Map()->Set(fstruct, res); + } + return res; } } |