summaryrefslogtreecommitdiff
path: root/src/jit/morph.cpp
diff options
context:
space:
mode:
authorBrian Sullivan <briansul@microsoft.com>2019-03-07 14:20:44 -0800
committerBrian Sullivan <briansul@microsoft.com>2019-03-13 15:23:35 -0700
commitef1d1e86da8406ca86ca98b8d92b038fe1f08d7a (patch)
tree334222be94dfdfad3951f23ad08daa2b16e652b2 /src/jit/morph.cpp
parente73c7bca3ebc46055cbdfb87adb39334474abb96 (diff)
downloadcoreclr-ef1d1e86da8406ca86ca98b8d92b038fe1f08d7a.tar.gz
coreclr-ef1d1e86da8406ca86ca98b8d92b038fe1f08d7a.tar.bz2
coreclr-ef1d1e86da8406ca86ca98b8d92b038fe1f08d7a.zip
Fix for Issue 21231
When transferring a Zero offset from one GenTree node to another, we need to check if there already is a FieldSeq and append to it. Added third parameter 'kind' to JitHashTable::Set, and Added enum SetKind Only allow Set to overwrite an existing entry when kind is set to Overwrite. Added validation for all calls to JitHashTable::Set asserting that we don't expect the key to already exist or that we passed Overwrite indicating that we expect to handle it properly. Added two test cases for Issue 21231
Diffstat (limited to 'src/jit/morph.cpp')
-rw-r--r--src/jit/morph.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/jit/morph.cpp b/src/jit/morph.cpp
index 48d97cfe4c..9d0193ba85 100644
--- a/src/jit/morph.cpp
+++ b/src/jit/morph.cpp
@@ -13640,8 +13640,15 @@ DONE_MORPHING_CHILDREN:
if (isZeroOffset)
{
+ // The "op1" node might already be annotated with a zero-offset field sequence.
+ FieldSeqNode* existingZeroOffsetFldSeq = nullptr;
+ if (GetZeroOffsetFieldMap()->Lookup(op1, &existingZeroOffsetFldSeq))
+ {
+ // Append the zero field sequences
+ zeroFieldSeq = GetFieldSeqStore()->Append(existingZeroOffsetFldSeq, zeroFieldSeq);
+ }
// Transfer the annotation to the new GT_ADDR node.
- GetZeroOffsetFieldMap()->Set(op1, zeroFieldSeq);
+ GetZeroOffsetFieldMap()->Set(op1, zeroFieldSeq, NodeToFieldSeqMap::Overwrite);
}
commaNode->gtOp.gtOp2 = op1;
// Originally, I gave all the comma nodes type "byref". But the ADDR(IND(x)) == x transform
@@ -18743,7 +18750,16 @@ void Compiler::fgAddFieldSeqForZeroOffset(GenTree* op1, FieldSeqNode* fieldSeq)
default:
// Record in the general zero-offset map.
- GetZeroOffsetFieldMap()->Set(op1, fieldSeq);
+
+ // The "op1" node might already be annotated with a zero-offset field sequence.
+ FieldSeqNode* existingZeroOffsetFldSeq = nullptr;
+ if (GetZeroOffsetFieldMap()->Lookup(op1, &existingZeroOffsetFldSeq))
+ {
+ // Append the zero field sequences
+ fieldSeq = GetFieldSeqStore()->Append(existingZeroOffsetFldSeq, fieldSeq);
+ }
+ // Set the new field sequence annotation for op1
+ GetZeroOffsetFieldMap()->Set(op1, fieldSeq, NodeToFieldSeqMap::Overwrite);
break;
}
}