Copy gtDebugFlags where necessary.
authorPat Gavlin <pagavlin@microsoft.com>
Sun, 26 Jun 2016 15:02:04 +0000 (08:02 -0700)
committerPat Gavlin <pagavlin@microsoft.com>
Sun, 26 Jun 2016 15:02:04 +0000 (08:02 -0700)
This also renames `GTF_DEBUG_MORPHED` to `GTF_DEBUG_NODE_MORPHED` for
consitency with the other node-specific debug flags.

src/jit/compiler.cpp
src/jit/gentree.cpp
src/jit/gentree.h
src/jit/morph.cpp
src/jit/optimizer.cpp

index 842cf68..425572a 100644 (file)
@@ -7661,7 +7661,7 @@ int cTreeFlagsIR(Compiler *comp, GenTree *tree)
             }
         }
 #endif // SMALL_TREE_NODES
-        if (tree->gtDebugFlags & GTF_DEBUG_MORPHED)
+        if (tree->gtDebugFlags & GTF_DEBUG_NODE_MORPHED)
         {
             chars += printf("[MORPHED]");
         }
index eb96980..a956c11 100644 (file)
@@ -2915,7 +2915,7 @@ bool                Compiler::gtIsLikelyRegVar(GenTree * tree)
  *         of operands the tree will push on the x87 (coprocessor) stack. Also sets
  *         genFPstkLevel, tmpDoubleSpillMax, and possibly gtFPstLvlRedo.
  *      5. Sometimes sets GTF_ADDRMODE_NO_CSE on nodes in the tree.
- *      6. DEBUG-only: clears GTF_DEBUG_MORPHED.
+ *      6. DEBUG-only: clears GTF_DEBUG_NODE_MORPHED.
  */
 
 #ifdef _PREFAST_
@@ -2928,8 +2928,8 @@ unsigned            Compiler::gtSetEvalOrder(GenTree * tree)
     assert(tree->gtOper != GT_STMT);
 
 #ifdef DEBUG
-    /* Clear the GTF_DEBUG_MORPHED flag as well */
-    tree->gtDebugFlags &= ~GTF_DEBUG_MORPHED;
+    /* Clear the GTF_DEBUG_NODE_MORPHED flag as well */
+    tree->gtDebugFlags &= ~GTF_DEBUG_NODE_MORPHED;
 #endif
 
     /* Is this a FP value? */
@@ -6340,6 +6340,10 @@ GenTreePtr          Compiler::gtClone(GenTree * tree, bool complexOK)
     }
 
     copy->gtFlags |= tree->gtFlags & ~GTF_NODE_MASK;
+#if defined(DEBUG)
+    copy->gtDebugFlags |= tree->gtDebugFlags & ~GTF_DEBUG_NODE_MASK;
+#endif // defined(DEBUG)
+
     return copy;
 }
 
@@ -6751,7 +6755,7 @@ GenTreePtr          Compiler::gtCloneExpr(GenTree * tree,
         }
 
         // We can call gtCloneExpr() before we have called fgMorph when we expand a GT_INDEX node in fgMorphArrayIndex()
-        // The method gtFoldExpr() expects to be run after fgMorph so it will set the GTF_DEBUG_MORPHED
+        // The method gtFoldExpr() expects to be run after fgMorph so it will set the GTF_DEBUG_NODE_MORPHED
         // flag on nodes that it adds/modifies.  Then when we call fgMorph we will assert.
         // We really only will need to fold when this method is used to replace references to 
         // local variable with an integer.
@@ -6960,6 +6964,11 @@ DONE:
     /* GTF_COLON_COND should be propagated from 'tree' to 'copy' */
     copy->gtFlags |= (tree->gtFlags & GTF_COLON_COND);
 
+#if defined(DEBUG)
+    // Non-node debug flags should be propagated from 'tree' to 'copy'
+    copy->gtDebugFlags |= (tree->gtDebugFlags & ~GTF_DEBUG_NODE_MASK);
+#endif
+
     /* Make sure to copy back fields that may have been initialized */
 
     copy->CopyRawCosts(tree);
@@ -7645,7 +7654,7 @@ GenTreePtr GenTree::GetChild(unsigned childNum)
     printf("%c", (flags & GTF_CALL          ) ? 'C' : '-');
     printf("%c", (flags & GTF_EXCEPT        ) ? 'X' : '-');
     printf("%c", (flags & GTF_GLOB_REF      ) ? 'G' : '-');
-    printf("%c", (debugFlags & GTF_DEBUG_MORPHED) ? '+' :     // First print '+' if GTF_DEBUG_MORPHED is set
+    printf("%c", (debugFlags & GTF_DEBUG_NODE_MORPHED) ? '+' :     // First print '+' if GTF_DEBUG_NODE_MORPHED is set
                  (flags & GTF_ORDER_SIDEEFF ) ? 'O' : '-');   // otherwise print 'O' or '-'
     printf("%c", (flags & GTF_COLON_COND    ) ? '?' : '-');
     printf("%c", (flags & GTF_DONT_CSE      ) ? 'N' :         // N is for No cse
index 36a9940..c3c0f39 100644 (file)
@@ -837,10 +837,12 @@ public:
     //----------------------------------------------------------------
 
 #if defined(DEBUG)
-    #define GTF_DEBUG_MORPHED         0x00000001  // the node has been morphed (in the global morphing phase)
+    #define GTF_DEBUG_NODE_MORPHED    0x00000001  // the node has been morphed (in the global morphing phase)
     #define GTF_DEBUG_NODE_SMALL      0x00000002
     #define GTF_DEBUG_NODE_LARGE      0x00000004
 
+    #define GTF_DEBUG_NODE_MASK       0x00000007  /// These flags are all node (rather than operation) properties.
+
     #define GTF_DEBUG_VAR_CSE_REF     0x00800000  // GT_LCL_VAR -- This is a CSE LCL_VAR node
 #endif // defined(DEBUG)
 
index c7ff161..7683fc7 100644 (file)
@@ -5445,7 +5445,7 @@ GenTreePtr          Compiler::fgMorphArrayIndex(GenTreePtr tree)
         }
     }
 
-    assert(!fgGlobalMorph || (arrElem->gtDebugFlags & GTF_DEBUG_MORPHED));
+    assert(!fgGlobalMorph || (arrElem->gtDebugFlags & GTF_DEBUG_NODE_MORPHED));
 
     addr = arrElem->gtOp.gtOp1;
 
@@ -7640,7 +7640,7 @@ NO_TAIL_CALL:
         copyBlk = fgMorphTree(copyBlk);
         GenTree* result = gtNewOperNode(GT_COMMA, TYP_VOID, call, copyBlk);
 #ifdef DEBUG
-        result->gtDebugFlags |= GTF_DEBUG_MORPHED;
+        result->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED;
 #endif
         return result;
     }
@@ -8319,7 +8319,7 @@ GenTreePtr          Compiler::fgMorphInitBlock(GenTreePtr tree)
     }
 
 #ifdef DEBUG
-    tree->gtDebugFlags |= GTF_DEBUG_MORPHED;
+    tree->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED;
 
     if (verbose)
     {
@@ -8951,7 +8951,7 @@ GenTreePtr          Compiler::fgMorphCopyBlock(GenTreePtr tree)
     }
 
 #ifdef DEBUG
-    tree->gtDebugFlags |= GTF_DEBUG_MORPHED;
+    tree->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED;
 
     if (verbose)
     {
@@ -9202,7 +9202,7 @@ GenTreePtr Compiler::fgMorphFieldToSIMDIntrinsicGet(GenTreePtr tree)
         GenTree* op2 = gtNewIconNode(index);   
         tree =  gtNewSIMDNode(baseType, simdStructNode, op2, SIMDIntrinsicGetItem, baseType, simdSize); 
 #ifdef DEBUG
-        tree->gtDebugFlags |= GTF_DEBUG_MORPHED;
+        tree->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED;
 #endif
     }
     return tree;
@@ -9265,7 +9265,7 @@ GenTreePtr  Compiler::fgMorphFieldAssignToSIMDIntrinsicSet(GenTreePtr tree)
                             gtNewIconNode(simdSize),
                             false);
 #ifdef DEBUG
-        tree->gtDebugFlags |= GTF_DEBUG_MORPHED;
+        tree->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED;
 #endif
     }
     
@@ -9684,7 +9684,7 @@ NO_MUL_64RSLT:
             {
                 GenTreePtr zeroNode = gtNewZeroConNode(typ);
 #ifdef DEBUG
-                zeroNode->gtDebugFlags |= GTF_DEBUG_MORPHED;
+                zeroNode->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED;
 #endif
                 DEBUG_DESTROY_NODE(tree);
                 return zeroNode;
@@ -11635,7 +11635,7 @@ CM_ADD_OP:
             commaNode->gtType = typ;
             commaNode->gtFlags = (treeFlags & ~GTF_REVERSE_OPS); // Bashing the GT_COMMA flags here is dangerous, clear the GTF_REVERSE_OPS at least.
 #ifdef DEBUG
-            commaNode->gtDebugFlags |= GTF_DEBUG_MORPHED;
+            commaNode->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED;
 #endif
             while (commaNode->gtOp.gtOp2->gtOper == GT_COMMA)
             {
@@ -11643,7 +11643,7 @@ CM_ADD_OP:
                 commaNode->gtType = typ;
                 commaNode->gtFlags = (treeFlags & ~GTF_REVERSE_OPS); // Bashing the GT_COMMA flags here is dangerous, clear the GTF_REVERSE_OPS at least.
 #ifdef DEBUG
-                commaNode->gtDebugFlags |= GTF_DEBUG_MORPHED;
+                commaNode->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED;
 #endif
             }
             bool wasArrIndex = (tree->gtFlags & GTF_IND_ARR_INDEX) != 0;
@@ -11662,7 +11662,7 @@ CM_ADD_OP:
                 GetArrayInfoMap()->Set(op1, arrInfo);
             }
 #ifdef DEBUG
-            op1->gtDebugFlags |= GTF_DEBUG_MORPHED;
+            op1->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED;
 #endif
             commaNode->gtOp.gtOp2 = op1;
             return tree;
@@ -11745,7 +11745,7 @@ CM_ADD_OP:
             {
                 commaNode->gtType = op1->gtType; commaNode->gtFlags |= op1->gtFlags;
 #ifdef DEBUG
-                commaNode->gtDebugFlags |= GTF_DEBUG_MORPHED;
+                commaNode->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED;
 #endif
                 commaNode = commaNode->gtOp.gtOp2;
             }
@@ -12743,7 +12743,7 @@ GenTree* Compiler::fgMorphModByConst(GenTreeOp* tree)
     GenTree* sub = gtNewOperNode(GT_SUB, type, numerator, mul);
 
 #ifdef DEBUG
-    sub->gtDebugFlags |= GTF_DEBUG_MORPHED;
+    sub->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED;
 #endif
 
     return sub;
@@ -12797,7 +12797,7 @@ GenTree* Compiler::fgMorphModToSubMulDiv(GenTreeOp* tree)
     GenTree* sub = gtNewOperNode(GT_SUB, type, gtCloneExpr(numerator), mul);
 
 #ifdef DEBUG
-    sub->gtDebugFlags |= GTF_DEBUG_MORPHED;
+    sub->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED;
 #endif
 
     return sub;
@@ -12883,7 +12883,7 @@ GenTree* Compiler::fgMorphDivByConst(GenTreeOp* tree)
     DISPTREE(result);
 
 #ifdef DEBUG
-    result->gtDebugFlags |= GTF_DEBUG_MORPHED;
+    result->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED;
 #endif
 
     return result;
@@ -13401,7 +13401,7 @@ GenTreePtr          Compiler::fgMorphTree(GenTreePtr tree, MorphAddrContext* mac
     if (fgGlobalMorph)
     {
         /* Ensure that we haven't morphed this node already */
-        assert(((tree->gtDebugFlags & GTF_DEBUG_MORPHED) == 0) && "ERROR: Already morphed this node!");
+        assert(((tree->gtDebugFlags & GTF_DEBUG_NODE_MORPHED) == 0) && "ERROR: Already morphed this node!");
 
 #if LOCAL_ASSERTION_PROP
         /* Before morphing the tree, we try to propagate any active assertions */
@@ -13607,7 +13607,7 @@ void                Compiler::fgKillDependentAssertions(unsigned lclNum
  *
  *  This function is called to complete the morphing of a tree node
  *  It should only be called once for each node.
- *  If DEBUG is defined the flag GTF_DEBUG_MORPHED is checked and updated,
+ *  If DEBUG is defined the flag GTF_DEBUG_NODE_MORPHED is checked and updated,
  *  to enforce the invariant that each node is only morphed once.
  *  If LOCAL_ASSERTION_PROP is enabled the result tree may be replaced
  *  by an equivalent tree.
@@ -13633,7 +13633,7 @@ void                Compiler::fgMorphTreeDone(GenTreePtr tree,
     if ((oldTree != NULL) && (oldTree != tree))
     {
         /* Ensure that we have morphed this node */
-        assert((tree->gtDebugFlags & GTF_DEBUG_MORPHED) && "ERROR: Did not morph this node!");
+        assert((tree->gtDebugFlags & GTF_DEBUG_NODE_MORPHED) && "ERROR: Did not morph this node!");
 
 #ifdef DEBUG
         TransferTestDataToNode(oldTree, tree);
@@ -13642,7 +13642,7 @@ void                Compiler::fgMorphTreeDone(GenTreePtr tree,
     else
     {
         // Ensure that we haven't morphed this node already 
-        assert(((tree->gtDebugFlags & GTF_DEBUG_MORPHED) == 0) && "ERROR: Already morphed this node!");
+        assert(((tree->gtDebugFlags & GTF_DEBUG_NODE_MORPHED) == 0) && "ERROR: Already morphed this node!");
     }
 
     if (tree->OperKind() & GTK_CONST)
@@ -13676,7 +13676,7 @@ DONE:;
 
 #ifdef DEBUG
     /* Mark this node as being morphed */
-    tree->gtDebugFlags |= GTF_DEBUG_MORPHED;
+    tree->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED;
 #endif
 }
 
@@ -14249,7 +14249,7 @@ void                Compiler::fgMorphStmts(BasicBlock * block,
                but the flag still got set, clear it here...  */
 
 #ifdef DEBUG
-            tree->gtDebugFlags &= ~GTF_DEBUG_MORPHED;
+            tree->gtDebugFlags &= ~GTF_DEBUG_NODE_MORPHED;
 #endif
             noway_assert(compTailCallUsed);
             noway_assert((tree->gtOper == GT_CALL) && tree->AsCall()->IsTailCall());
index 3993be8..bcca2a6 100644 (file)
@@ -4849,7 +4849,7 @@ bool                Compiler::optNarrowTree(GenTreePtr     tree,
                         assert(tree->gtType == TYP_INT);
                         op1 = gtNewCastNode(TYP_INT, op1, TYP_INT);
 #ifdef DEBUG
-                        op1->gtDebugFlags |= GTF_DEBUG_MORPHED;
+                        op1->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED;
 #endif
                         tree->gtOp.gtOp1 = op1;
                     }