From b36a217417794a7dd1cce412f5bc412f06046130 Mon Sep 17 00:00:00 2001 From: Pat Gavlin Date: Wed, 7 Dec 2016 09:02:02 -0800 Subject: [PATCH] Remove a use of `gtGetOp` in earlyprop. Instead, use `GenTreeIndir::Addr`, as some indirections are not simple operators. Fixes VSO 289704. Commit migrated from https://github.com/dotnet/coreclr/commit/95de3a09c7adca51e1f56eb295cfb1b6e26801db --- src/coreclr/src/jit/earlyprop.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/coreclr/src/jit/earlyprop.cpp b/src/coreclr/src/jit/earlyprop.cpp index 7bf6eab..51de631 100644 --- a/src/coreclr/src/jit/earlyprop.cpp +++ b/src/coreclr/src/jit/earlyprop.cpp @@ -512,14 +512,17 @@ void Compiler::optFoldNullCheck(GenTreePtr tree) } assert(tree->OperIsIndir()); - if (tree->AsIndir()->Addr()->OperGet() == GT_LCL_VAR) + + GenTree* const addr = tree->AsIndir()->Addr(); + if (addr->OperGet() == GT_LCL_VAR) { // Check if we have the pattern above and find the nullcheck node if we do. // Find the definition of the indirected local (x in the picture) - GenTreePtr indLocalTree = tree->gtGetOp1(); - unsigned lclNum = indLocalTree->AsLclVarCommon()->GetLclNum(); - unsigned ssaNum = indLocalTree->AsLclVarCommon()->GetSsaNum(); + GenTreeLclVarCommon* const lclVarNode = addr->AsLclVarCommon(); + + const unsigned lclNum = lclVarNode->GetLclNum(); + const unsigned ssaNum = lclVarNode->GetSsaNum(); if (ssaNum != SsaConfig::RESERVED_SSA_NUM) { @@ -557,7 +560,7 @@ void Compiler::optFoldNullCheck(GenTreePtr tree) { // Walk from the use to the def in reverse execution order to see // if any nodes have unsafe side effects. - GenTreePtr currentTree = indLocalTree->gtPrev; + GenTreePtr currentTree = lclVarNode->gtPrev; bool isInsideTry = compCurBB->hasTryIndex(); bool canRemoveNullCheck = true; const unsigned maxNodesWalked = 25; -- 2.7.4