From 43e5f18ff826058a4de71491a378e5b94ecec919 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Tue, 26 Jul 2016 14:19:20 -0700 Subject: [PATCH] Rewrite gtIsVtableAccess to avoid assert 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 | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/jit/earlyprop.cpp b/src/jit/earlyprop.cpp index da1228e..ff74d3a 100644 --- a/src/jit/earlyprop.cpp +++ b/src/jit/earlyprop.cpp @@ -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)); } } -- 2.7.4