From 736291405ac4daf4fa84d11183e8be2bdf294425 Mon Sep 17 00:00:00 2001 From: Sergey Andreenko Date: Thu, 25 Apr 2019 14:59:33 -0700 Subject: Add comments and format `gtGetThisArg`. --- src/jit/gentree.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/jit/gentree.cpp') diff --git a/src/jit/gentree.cpp b/src/jit/gentree.cpp index 9e58db0df4..5be016027f 100644 --- a/src/jit/gentree.cpp +++ b/src/jit/gentree.cpp @@ -7931,23 +7931,29 @@ bool Compiler::gtCompareTree(GenTree* op1, GenTree* op2) GenTree* Compiler::gtGetThisArg(GenTreeCall* call) { - if (call->gtCallObjp != nullptr) + GenTree* thisArg = call->gtCallObjp; + if (thisArg != nullptr) { - if (call->gtCallObjp->gtOper != GT_NOP && call->gtCallObjp->gtOper != GT_ASG) + if (thisArg->OperIs(GT_NOP, GT_ASG) == false) { - if (!(call->gtCallObjp->gtFlags & GTF_LATE_ARG)) + if ((thisArg->gtFlags & GTF_LATE_ARG) == 0) { return call->gtCallObjp; } } - if (call->gtCallLateArgs) + if (call->gtCallLateArgs != nullptr) { unsigned argNum = 0; fgArgTabEntry* thisArgTabEntry = gtArgEntryByArgNum(call, argNum); GenTree* result = thisArgTabEntry->node; #if !FEATURE_FIXED_OUT_ARGS && defined(DEBUG) + // Check that call->fgArgInfo used in gtArgEntryByArgNum was not + // left outdated by assertion propogation updates. + // There is no information about registers of late args for platforms + // with FEATURE_FIXED_OUT_ARGS that is why this debug check is under + // !FEATURE_FIXED_OUT_ARGS. regNumber thisReg = REG_ARG_0; GenTree* lateArgs = call->gtCallLateArgs; regList list = call->regArgList; -- cgit v1.2.3 From 332bd2ec8a6bad66e1fb9b2dc3cf37e9e4d77727 Mon Sep 17 00:00:00 2001 From: Sergey Andreenko Date: Thu, 25 Apr 2019 16:05:51 -0700 Subject: Change gtFindLink to return parent as well. --- src/jit/gentree.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/jit/gentree.cpp') diff --git a/src/jit/gentree.cpp b/src/jit/gentree.cpp index 5be016027f..f5a7982243 100644 --- a/src/jit/gentree.cpp +++ b/src/jit/gentree.cpp @@ -7948,6 +7948,9 @@ GenTree* Compiler::gtGetThisArg(GenTreeCall* call) fgArgTabEntry* thisArgTabEntry = gtArgEntryByArgNum(call, argNum); GenTree* result = thisArgTabEntry->node; + // Assert if we used DEBUG_DESTROY_NODE. + assert(result->gtOper != GT_COUNT); + #if !FEATURE_FIXED_OUT_ARGS && defined(DEBUG) // Check that call->fgArgInfo used in gtArgEntryByArgNum was not // left outdated by assertion propogation updates. @@ -7972,6 +7975,7 @@ GenTree* Compiler::gtGetThisArg(GenTreeCall* call) index++; } #endif // !FEATURE_FIXED_OUT_ARGS && defined(DEBUG) + return result; } } @@ -15162,42 +15166,37 @@ Compiler::fgWalkResult Compiler::gtClearColonCond(GenTree** pTree, fgWalkData* d return WALK_CONTINUE; } -struct FindLinkData -{ - GenTree* nodeToFind; - GenTree** result; -}; - /***************************************************************************** * * Callback used by the tree walker to implement fgFindLink() */ static Compiler::fgWalkResult gtFindLinkCB(GenTree** pTree, Compiler::fgWalkData* cbData) { - FindLinkData* data = (FindLinkData*)cbData->pCallbackData; + Compiler::FindLinkData* data = (Compiler::FindLinkData*)cbData->pCallbackData; if (*pTree == data->nodeToFind) { data->result = pTree; + data->parent = cbData->parent; return Compiler::WALK_ABORT; } return Compiler::WALK_CONTINUE; } -GenTree** Compiler::gtFindLink(GenTreeStmt* stmt, GenTree* node) +Compiler::FindLinkData Compiler::gtFindLink(GenTreeStmt* stmt, GenTree* node) { - FindLinkData data = {node, nullptr}; + FindLinkData data = {node, nullptr, nullptr}; fgWalkResult result = fgWalkTreePre(&stmt->gtStmtExpr, gtFindLinkCB, &data); if (result == WALK_ABORT) { assert(data.nodeToFind == *data.result); - return data.result; + return data; } else { - return nullptr; + return {node, nullptr, nullptr}; } } -- cgit v1.2.3