From caaca713decbaefa91d55973f18600786714448a Mon Sep 17 00:00:00 2001 From: Pat Gavlin Date: Mon, 22 Aug 2016 14:01:31 -0700 Subject: [PATCH] Remove fgDebugCheckLinear{Tree,NodeLinks}. (#6842) These functions are not necessary for LIR. --- src/jit/compiler.h | 2 - src/jit/flowgraph.cpp | 166 -------------------------------------------------- 2 files changed, 168 deletions(-) diff --git a/src/jit/compiler.h b/src/jit/compiler.h index 73d0d95..0d76b84 100644 --- a/src/jit/compiler.h +++ b/src/jit/compiler.h @@ -4198,8 +4198,6 @@ public: void fgDebugCheckBlockLinks(); void fgDebugCheckLinks(bool morphTrees = false); void fgDebugCheckNodeLinks(BasicBlock* block, GenTreePtr stmt); - unsigned fgDebugCheckLinearTree(BasicBlock* block, GenTreePtr stmt, GenTreePtr tree, bool printNodes = false); - void fgDebugCheckLinearNodeLinks(BasicBlock* block, GenTreePtr topLevelStmt, bool printNodes = false); void fgDebugCheckFlags(GenTreePtr tree); #endif diff --git a/src/jit/flowgraph.cpp b/src/jit/flowgraph.cpp index bac9a49..66b3efb 100644 --- a/src/jit/flowgraph.cpp +++ b/src/jit/flowgraph.cpp @@ -20494,11 +20494,6 @@ void Compiler::fgDebugCheckNodeLinks(BasicBlock* block, GenTree* node) GenTreeStmt* stmt = node->AsStmt(); assert(fgStmtListThreaded); - if (fgOrder == FGOrderLinear) // remove for LIR? - { - fgDebugCheckLinearNodeLinks(block, stmt); - return; - } noway_assert(stmt->gtStmtList); @@ -20596,167 +20591,6 @@ void Compiler::fgDebugCheckNodeLinks(BasicBlock* block, GenTree* node) } } -// TODO-LIR: remove? -//------------------------------------------------------------------------ -// fgDebugCheckLinearTree: Counts the nodes in a tree by doing a tree traversal, -// and validates that GT_CATCH_ARG causes GTF_ORDER_SIDEEFF to be set on -// itself and its containing statement. -// -// Arguments: -// block - The block containing 'tree' -// stmt - The statement containing 'tree' -// tree - The tree to be checked -// printNodes - In case DebugCheckLinearNodeLinks detects a problem, we re-run -// printing the tree order traversal node by node for debugging purposes. -// Return Value: -// Returns the count of nodes in the tree. -// -// Notes: -// This is called by fgDebugCheckLinearNodeLinks(), which uses the node -// count from the tree walk to validate against the node count from a -// linear traversal. - -unsigned Compiler::fgDebugCheckLinearTree(BasicBlock* block, - GenTreePtr stmt, - GenTreePtr tree, - bool printNodes) -{ - if (printNodes) - { - DISPNODE(tree); - } - - unsigned nodeCount = 1; - if (tree->OperIsLeaf()) - { - if (tree->gtOper == GT_CATCH_ARG) - { - // The GT_CATCH_ARG should always have GTF_ORDER_SIDEEFF set - noway_assert(tree->gtFlags & GTF_ORDER_SIDEEFF); - // The GT_CATCH_ARG has to be the first thing evaluated - noway_assert(stmt == block->FirstNonPhiDef()); - noway_assert(stmt->gtStmt.gtStmtList->gtOper == GT_CATCH_ARG); - // The root of the tree should have GTF_ORDER_SIDEEFF set - noway_assert(stmt->gtStmt.gtStmtExpr->gtFlags & GTF_ORDER_SIDEEFF); - } - } - else - { - // Do per-node checks - - // Visit children - unsigned childCount = tree->NumChildren(); - for (unsigned i = 0; - i < childCount; - i++) - { - GenTreePtr child = tree->GetChild(i); - nodeCount += fgDebugCheckLinearTree(block, stmt, child, printNodes); - } - } - return nodeCount; -} - -// TODO-LIR: remove function? -//------------------------------------------------------------------------ -// fgDebugCheckLinearNodeLinks: DEBUG routine to check correctness of the internal -// gtNext, gtPrev threading of a statement. -// -// Arguments: -// block - The block containing 'topLevelStmt' -// topLevelStmt - The statement to be checked -// printNodes - 'true' if we are to print the nodes while we check them. -// -// Return Value: -// None. -// -// Notes: -// This function is the called by fgDebugCheckNodeLinks when fgOrder == FGOrderLinear, -// and is only valid when fgStmtListThreaded is true and fgOrder == FGOrderLinear. -// It compares the number of nodes encountered in tree-walking 'topLevelStmt' and all -// of its embedded statements, against the number of nodes in a linear traversal. -void Compiler::fgDebugCheckLinearNodeLinks(BasicBlock* block, - GenTreePtr topLevelStmt, - bool printNodes) -{ - assert(!block->IsLIR()); - assert(fgStmtListThreaded); - assert(fgOrder == FGOrderLinear); - assert(topLevelStmt->gtOper == GT_STMT); - - // We're first going to traverse the statements in linear order, counting the nodes and ensuring that - // the links are consistent. - // We should be able to reach all the nodes by starting with topLevelStmt->gtStmt.gtStmtList. - - unsigned linearNodeCount = 0; - - if (printNodes) - { - JITDUMP("\nChecking linear order first:\n"); - } - - noway_assert(topLevelStmt->gtStmt.gtStmtList); - - // The first node's gtPrev must be nullptr (the gtPrev list is not circular). - // The last node's gtNext must be nullptr (the gtNext list is not circular). This is tested if the loop below terminates. - noway_assert(topLevelStmt->gtStmt.gtStmtList->gtPrev == nullptr); - - for (GenTreePtr tree = topLevelStmt->gtStmt.gtStmtList; - tree != nullptr; - tree = tree->gtNext) - { - if (printNodes) - { - DISPNODE(tree); - } - - linearNodeCount++; - if (tree->gtPrev) - { - noway_assert(tree->gtPrev->gtNext == tree); - } - else - { - // Because the embedded trees are fully contained within the topLevelStmt, the last node - // we encounter must be the top-level node of the top-level statement. - noway_assert(tree == topLevelStmt->gtStmt.gtStmtList); - } - - if (tree->gtNext) - { - noway_assert(tree->gtNext->gtPrev == tree); - } - else - { - noway_assert(tree == topLevelStmt->gtStmt.gtStmtExpr); - } - } - - // Next, we're going to traverse the statements in tree order, ensuring that we encounter the right - // number of nodes. - // Stop when we reach the next top-level statement (or nullptr) - - unsigned treeNodeCount = 0; - GenTreeStmt* stmt = topLevelStmt->AsStmt(); - - if (printNodes) - { - JITDUMP("\nNow checking tree-ordering:\n"); - } - - treeNodeCount += fgDebugCheckLinearTree(block, stmt, stmt->gtStmtExpr, printNodes); - - if (treeNodeCount != linearNodeCount) - { - if (!printNodes) - { - JITDUMP("Tree order vs linear order counts differed!\n"); - fgDebugCheckLinearNodeLinks(block, topLevelStmt, true); - } - } - assert (treeNodeCount == linearNodeCount); -} - /***************************************************************************** * -- 2.7.4