diff options
author | Brian Sullivan <briansul@microsoft.com> | 2019-03-15 14:55:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-15 14:55:51 -0700 |
commit | 037fb36a35f8e8f8a4cae4701608142e687b376f (patch) | |
tree | d233077cb953f577d3d4936e08d55fd0585a6a3a | |
parent | 3a029763047b5144e9fdca7f4c0d70553ddbf2e8 (diff) | |
parent | 6a773c4a849048b65b62940e3c060144cbd31f01 (diff) | |
download | coreclr-037fb36a35f8e8f8a4cae4701608142e687b376f.tar.gz coreclr-037fb36a35f8e8f8a4cae4701608142e687b376f.tar.bz2 coreclr-037fb36a35f8e8f8a4cae4701608142e687b376f.zip |
Merge pull request #23272 from briansull/VNMap_Overwrite
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; } } |