private static void StoreMethodLocalValue <KeyType> ( Dictionary <KeyType, ValueBasicBlockPair> valueCollection, ValueNode valueToStore, KeyType collectionKey, int curBasicBlock) { ValueBasicBlockPair newValue = new ValueBasicBlockPair { BasicBlockIndex = curBasicBlock }; ValueBasicBlockPair existingValue; if (valueCollection.TryGetValue(collectionKey, out existingValue) && existingValue.BasicBlockIndex == curBasicBlock) { // If the previous value was stored in the current basic block, then we can safely // overwrite the previous value with the new one. newValue.Value = valueToStore; } else { // If the previous value came from a previous basic block, then some other use of // the local could see the previous value, so we must merge the new value with the // old value. newValue.Value = MergePointValue.MergeValues(existingValue.Value, valueToStore); } valueCollection[collectionKey] = newValue; }
private static void StoreMethodLocalValue <KeyType> ( Dictionary <KeyType, ValueBasicBlockPair> valueCollection, ValueNode?valueToStore, KeyType collectionKey, int curBasicBlock, int?maxTrackedValues = null) where KeyType : notnull { ValueBasicBlockPair newValue = new ValueBasicBlockPair { BasicBlockIndex = curBasicBlock }; ValueBasicBlockPair existingValue; if (valueCollection.TryGetValue(collectionKey, out existingValue)) { if (existingValue.BasicBlockIndex == curBasicBlock) { // If the previous value was stored in the current basic block, then we can safely // overwrite the previous value with the new one. newValue.Value = valueToStore; } else { // If the previous value came from a previous basic block, then some other use of // the local could see the previous value, so we must merge the new value with the // old value. newValue.Value = MergePointValue.MergeValues(existingValue.Value, valueToStore); } valueCollection[collectionKey] = newValue; } else if (maxTrackedValues == null || valueCollection.Count < maxTrackedValues) { // We're not currently tracking a value a this index, so store the value now. newValue.Value = valueToStore; valueCollection[collectionKey] = newValue; } }