Address PR feedback.
authorPat Gavlin <pagavlin@microsoft.com>
Thu, 8 Jun 2017 02:22:51 +0000 (19:22 -0700)
committerPat Gavlin <pagavlin@microsoft.com>
Thu, 8 Jun 2017 02:22:51 +0000 (19:22 -0700)
src/jit/lir.cpp
src/jit/smallhash.h

index a616323..4d0a769 100644 (file)
@@ -1573,8 +1573,11 @@ bool LIR::Range::CheckLIR(Compiler* compiler, bool checkUnusedValues) const
             AliasSet::NodeInfo operandInfo(compiler, operand);
             if (operandInfo.IsLclVarRead())
             {
-                int count = 0;
-                if (unconsumedLclVarReads.TryRemove(operandInfo.LclNum(), &count) && count > 1)
+                int count;
+                const bool removed = unconsumedLclVarReads.TryRemove(operandInfo.LclNum(), &count);
+                assert(removed);
+
+                if (count > 1)
                 {
                     unconsumedLclVarReads.AddOrUpdate(operandInfo.LclNum(), count - 1);
                 }
@@ -1582,20 +1585,15 @@ bool LIR::Range::CheckLIR(Compiler* compiler, bool checkUnusedValues) const
         }
 
         AliasSet::NodeInfo nodeInfo(compiler, node);
-
-        bool unused;
-        if (nodeInfo.IsLclVarRead() && !unusedDefs.TryGetValue(node, &unused))
+        if (nodeInfo.IsLclVarRead() && !unusedDefs.Contains(node))
         {
             int count = 0;
             unconsumedLclVarReads.TryGetValue(nodeInfo.LclNum(), &count);
             unconsumedLclVarReads.AddOrUpdate(nodeInfo.LclNum(), count + 1);
         }
 
-        if (nodeInfo.IsLclVarWrite())
-        {
-            int unused;
-            assert(!unconsumedLclVarReads.TryGetValue(nodeInfo.LclNum(), &unused));
-        }
+        // If this node is a lclVar write, it must be to a lclVar that does not have an outstanding read.
+        assert(!nodeInfo.IsLclVarWrite() || !unconsumedLclVarReads.Contains(nodeInfo.LclNum()));
     }
 
     return true;
index b9681de..65c5eed 100644 (file)
@@ -579,6 +579,21 @@ public:
         *value = m_buckets[index].m_value;
         return true;
     }
+
+    //------------------------------------------------------------------------
+    // HashTableBase::Contains: returns true if a key exists in the table and
+    //                          false otherwise.
+    //
+    // Arguments:
+    //    key   - The key to find from the table.
+    //
+    // Returns:
+    //    True if the key was found in the table; false otherwise.
+    bool Contains(const TKey& key) const
+    {
+        unsigned unused, index;
+        return TryGetBucket(TKeyInfo::GetHashCode(key), key, &unused, &index);
+    }
 };
 
 //------------------------------------------------------------------------