Rewrite gtIsVtableAccess to avoid assert
authorAndy Ayers <andya@microsoft.com>
Tue, 26 Jul 2016 21:19:20 +0000 (14:19 -0700)
committerAndy Ayers <andya@microsoft.com>
Tue, 26 Jul 2016 21:19:20 +0000 (14:19 -0700)
Calling `HasIndex` from `gtIsVtableAccess` can leads to asserts as the
underly code checks to see if the addressing sub-expressions are
contained. But earlyProp runs early enough that it is not concerned with
containment. The code just needs to verify that there is a ref type base
and no index. Rework the code to do the checks directly.

src/jit/earlyprop.cpp

index da1228e..ff74d3a 100644 (file)
@@ -43,15 +43,14 @@ bool Compiler::gtIsVtableRef(GenTreePtr tree)
 {
     if (tree->OperGet() == GT_IND)
     {
-        GenTreeIndir* indir = tree->AsIndir();
+        GenTree* addr = tree->AsIndir()->Addr();
 
-        if (!indir->HasIndex())
+        if (addr->OperIsAddrMode())
         {
-            // Check if the base is an reference pointer.
-            if (indir->Base()->TypeGet() == TYP_REF)
-            {
-                return true;
-            }
+            GenTreeAddrMode* addrMode = addr->AsAddrMode();
+
+            return (!addrMode->HasIndex() &&
+                    (addrMode->Base()->TypeGet() == TYP_REF));
         }
     }