private static void StoreMethodLocalValue( ValueBasicBlockPair[] valueCollection, ValueNode valueToStore, int index, int curBasicBlock) { ValueBasicBlockPair newValue = new ValueBasicBlockPair { BasicBlockIndex = curBasicBlock }; ValueBasicBlockPair existingValue = valueCollection[index]; if (existingValue.Value != null && 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[index] = newValue; }
private static StackSlot MergeStackElement(StackSlot a, StackSlot b) { StackSlot mergedSlot; if (b.Value == null) { mergedSlot = a; } else if (a.Value == null) { mergedSlot = b; } else { mergedSlot = new StackSlot(MergePointValue.MergeValues(a.Value, b.Value)); } return(mergedSlot); }
private static void StoreMethodLocalValue <KeyType>( Dictionary <KeyType, ValueBasicBlockPair> valueCollection, ValueNode valueToStore, KeyType collectionKey, int curBasicBlock, int?maxTrackedValues = null) { 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; } }