return returnVal;
}
-
-//------------------------------------------------------------------------------
-// DisplayStaticSizes: display various static sizes of the BasicBlock data structure.
-//
-// Arguments:
-// fout - where to write the output
-//
-// Return Value:
-// None
-//
-// Note: This function only does something if MEASURE_BLOCK_SIZE is defined, which it might
-// be in private Release builds.
-//
-/* static */
-void BasicBlock::DisplayStaticSizes(FILE* fout)
-{
-#if MEASURE_BLOCK_SIZE
-
- BasicBlock* bbDummy = nullptr;
-
- fprintf(fout, "\n");
- fprintf(fout, "Offset / size of bbNext = %3u / %3u\n", offsetof(BasicBlock, bbNext),
- sizeof(bbDummy->bbNext));
- fprintf(fout, "Offset / size of bbPrev = %3u / %3u\n", offsetof(BasicBlock, bbPrev),
- sizeof(bbDummy->bbPrev));
- fprintf(fout, "Offset / size of bbFlags = %3u / %3u\n", offsetof(BasicBlock, bbFlags),
- sizeof(bbDummy->bbFlags));
- fprintf(fout, "Offset / size of bbNum = %3u / %3u\n", offsetof(BasicBlock, bbNum),
- sizeof(bbDummy->bbNum));
- fprintf(fout, "Offset / size of bbPostOrderNum = %3u / %3u\n", offsetof(BasicBlock, bbPostOrderNum),
- sizeof(bbDummy->bbPostOrderNum));
- fprintf(fout, "Offset / size of bbRefs = %3u / %3u\n", offsetof(BasicBlock, bbRefs),
- sizeof(bbDummy->bbRefs));
- fprintf(fout, "Offset / size of bbWeight = %3u / %3u\n", offsetof(BasicBlock, bbWeight),
- sizeof(bbDummy->bbWeight));
- fprintf(fout, "Offset / size of bbJumpKind = %3u / %3u\n", offsetof(BasicBlock, bbJumpKind),
- sizeof(bbDummy->bbJumpKind));
- fprintf(fout, "Offset / size of bbJumpOffs = %3u / %3u\n", offsetof(BasicBlock, bbJumpOffs),
- sizeof(bbDummy->bbJumpOffs));
- fprintf(fout, "Offset / size of bbJumpDest = %3u / %3u\n", offsetof(BasicBlock, bbJumpDest),
- sizeof(bbDummy->bbJumpDest));
- fprintf(fout, "Offset / size of bbJumpSwt = %3u / %3u\n", offsetof(BasicBlock, bbJumpSwt),
- sizeof(bbDummy->bbJumpSwt));
- fprintf(fout, "Offset / size of bbEntryState = %3u / %3u\n", offsetof(BasicBlock, bbEntryState),
- sizeof(bbDummy->bbEntryState));
- fprintf(fout, "Offset / size of bbStkTempsIn = %3u / %3u\n", offsetof(BasicBlock, bbStkTempsIn),
- sizeof(bbDummy->bbStkTempsIn));
- fprintf(fout, "Offset / size of bbStkTempsOut = %3u / %3u\n", offsetof(BasicBlock, bbStkTempsOut),
- sizeof(bbDummy->bbStkTempsOut));
- fprintf(fout, "Offset / size of bbTryIndex = %3u / %3u\n", offsetof(BasicBlock, bbTryIndex),
- sizeof(bbDummy->bbTryIndex));
- fprintf(fout, "Offset / size of bbHndIndex = %3u / %3u\n", offsetof(BasicBlock, bbHndIndex),
- sizeof(bbDummy->bbHndIndex));
- fprintf(fout, "Offset / size of bbCatchTyp = %3u / %3u\n", offsetof(BasicBlock, bbCatchTyp),
- sizeof(bbDummy->bbCatchTyp));
- fprintf(fout, "Offset / size of bbStkDepth = %3u / %3u\n", offsetof(BasicBlock, bbStkDepth),
- sizeof(bbDummy->bbStkDepth));
- fprintf(fout, "Offset / size of bbFPinVars = %3u / %3u\n", offsetof(BasicBlock, bbFPinVars),
- sizeof(bbDummy->bbFPinVars));
- fprintf(fout, "Offset / size of bbCheapPreds = %3u / %3u\n", offsetof(BasicBlock, bbCheapPreds),
- sizeof(bbDummy->bbCheapPreds));
- fprintf(fout, "Offset / size of bbPreds = %3u / %3u\n", offsetof(BasicBlock, bbPreds),
- sizeof(bbDummy->bbPreds));
- fprintf(fout, "Offset / size of bbReach = %3u / %3u\n", offsetof(BasicBlock, bbReach),
- sizeof(bbDummy->bbReach));
- fprintf(fout, "Offset / size of bbIDom = %3u / %3u\n", offsetof(BasicBlock, bbIDom),
- sizeof(bbDummy->bbIDom));
- fprintf(fout, "Offset / size of bbDfsNum = %3u / %3u\n", offsetof(BasicBlock, bbDfsNum),
- sizeof(bbDummy->bbDfsNum));
- fprintf(fout, "Offset / size of bbCodeOffs = %3u / %3u\n", offsetof(BasicBlock, bbCodeOffs),
- sizeof(bbDummy->bbCodeOffs));
- fprintf(fout, "Offset / size of bbCodeOffsEnd = %3u / %3u\n", offsetof(BasicBlock, bbCodeOffsEnd),
- sizeof(bbDummy->bbCodeOffsEnd));
- fprintf(fout, "Offset / size of bbVarUse = %3u / %3u\n", offsetof(BasicBlock, bbVarUse),
- sizeof(bbDummy->bbVarUse));
- fprintf(fout, "Offset / size of bbVarDef = %3u / %3u\n", offsetof(BasicBlock, bbVarDef),
- sizeof(bbDummy->bbVarDef));
- fprintf(fout, "Offset / size of bbLiveIn = %3u / %3u\n", offsetof(BasicBlock, bbLiveIn),
- sizeof(bbDummy->bbLiveIn));
- fprintf(fout, "Offset / size of bbLiveOut = %3u / %3u\n", offsetof(BasicBlock, bbLiveOut),
- sizeof(bbDummy->bbLiveOut));
- // Can't do bitfield bbMemoryUse, bbMemoryDef, bbMemoryLiveIn, bbMemoryLiveOut, bbMemoryHavoc
- fprintf(fout, "Offset / size of bbMemorySsaPhiFunc = %3u / %3u\n", offsetof(BasicBlock, bbMemorySsaPhiFunc),
- sizeof(bbDummy->bbMemorySsaPhiFunc));
- fprintf(fout, "Offset / size of bbMemorySsaNumIn = %3u / %3u\n", offsetof(BasicBlock, bbMemorySsaNumIn),
- sizeof(bbDummy->bbMemorySsaNumIn));
- fprintf(fout, "Offset / size of bbMemorySsaNumOut = %3u / %3u\n", offsetof(BasicBlock, bbMemorySsaNumOut),
- sizeof(bbDummy->bbMemorySsaNumOut));
- fprintf(fout, "Offset / size of bbScope = %3u / %3u\n", offsetof(BasicBlock, bbScope),
- sizeof(bbDummy->bbScope));
- fprintf(fout, "Offset / size of bbCseGen = %3u / %3u\n", offsetof(BasicBlock, bbCseGen),
- sizeof(bbDummy->bbCseGen));
-#if ASSERTION_PROP
- fprintf(fout, "Offset / size of bbAssertionGen = %3u / %3u\n", offsetof(BasicBlock, bbAssertionGen),
- sizeof(bbDummy->bbAssertionGen));
-#endif // ASSERTION_PROP
- fprintf(fout, "Offset / size of bbCseIn = %3u / %3u\n", offsetof(BasicBlock, bbCseIn),
- sizeof(bbDummy->bbCseIn));
-#if ASSERTION_PROP
- fprintf(fout, "Offset / size of bbAssertionIn = %3u / %3u\n", offsetof(BasicBlock, bbAssertionIn),
- sizeof(bbDummy->bbAssertionIn));
-#endif // ASSERTION_PROP
- fprintf(fout, "Offset / size of bbCseOut = %3u / %3u\n", offsetof(BasicBlock, bbCseOut),
- sizeof(bbDummy->bbCseOut));
-#if ASSERTION_PROP
- fprintf(fout, "Offset / size of bbAssertionOut = %3u / %3u\n", offsetof(BasicBlock, bbAssertionOut),
- sizeof(bbDummy->bbAssertionOut));
-#endif // ASSERTION_PROP
- fprintf(fout, "Offset / size of bbEmitCookie = %3u / %3u\n", offsetof(BasicBlock, bbEmitCookie),
- sizeof(bbDummy->bbEmitCookie));
-
-#if defined(FEATURE_EH_FUNCLETS) && defined(_TARGET_ARM_)
- fprintf(fout, "Offset / size of bbUnwindNopEmitCookie = %3u / %3u\n", offsetof(BasicBlock, bbUnwindNopEmitCookie),
- sizeof(bbDummy->bbUnwindNopEmitCookie));
-#endif // defined(FEATURE_EH_FUNCLETS) && defined(_TARGET_ARM_)
-
-#ifdef VERIFIER
- fprintf(fout, "Offset / size of bbStackIn = %3u / %3u\n", offsetof(BasicBlock, bbStackIn),
- sizeof(bbDummy->bbStackIn));
- fprintf(fout, "Offset / size of bbStackOut = %3u / %3u\n", offsetof(BasicBlock, bbStackOut),
- sizeof(bbDummy->bbStackOut));
- fprintf(fout, "Offset / size of bbTypesIn = %3u / %3u\n", offsetof(BasicBlock, bbTypesIn),
- sizeof(bbDummy->bbTypesIn));
- fprintf(fout, "Offset / size of bbTypesOut = %3u / %3u\n", offsetof(BasicBlock, bbTypesOut),
- sizeof(bbDummy->bbTypesOut));
-#endif // VERIFIER
-
-#ifdef DEBUG
- fprintf(fout, "Offset / size of bbLoopNum = %3u / %3u\n", offsetof(BasicBlock, bbLoopNum),
- sizeof(bbDummy->bbLoopNum));
-#endif // DEBUG
-
- fprintf(fout, "Offset / size of bbNatLoopNum = %3u / %3u\n", offsetof(BasicBlock, bbNatLoopNum),
- sizeof(bbDummy->bbNatLoopNum));
-
- fprintf(fout, "\n");
- fprintf(fout, "Size of BasicBlock = %3u\n", sizeof(BasicBlock));
-
-#endif // MEASURE_BLOCK_SIZE
-}
}
}
+//------------------------------------------------------------------------
+// fgComputeDoms: Compute immediate dominators, the dominator tree and
+// and its pre/post-order travsersal numbers.
+//
+// Notes:
+// Immediate dominator computation is based on "A Simple, Fast Dominance Algorithm"
+// by Keith D. Cooper, Timothy J. Harvey, and Ken Kennedy.
+//
void Compiler::fgComputeDoms()
{
assert(!fgCheapPredsValid);
BlockSet processedBlks(BlockSetOps::MakeEmpty(this));
- fgBBInvPostOrder = new (this, CMK_DominatorMemory) BasicBlock*[fgBBNumMax + 1];
- memset(fgBBInvPostOrder, 0, sizeof(BasicBlock*) * (fgBBNumMax + 1));
+ fgBBInvPostOrder = new (this, CMK_DominatorMemory) BasicBlock*[fgBBNumMax + 1]{};
fgDfsInvPostOrder();
noway_assert(fgBBInvPostOrder[0] == nullptr);
JITDUMP("\nInside fgBuildDomTree\n");
unsigned bbArraySize = fgBBNumMax + 1;
- DomTreeNode* domTree = new (this, CMK_DominatorMemory) DomTreeNode[bbArraySize];
-
- // Initialize all the data structures.
- for (unsigned i = 0; i < bbArraySize; ++i)
- {
- domTree[i].firstChild = nullptr;
- domTree[i].nextSibling = nullptr;
- }
+ DomTreeNode* domTree = new (this, CMK_DominatorMemory) DomTreeNode[bbArraySize]{};
BasicBlock* imaginaryRoot = fgFirstBB->bbIDom;
// If the imaginary root is present then we'll need to create a forest instead of a tree.
// Forest roots are chained via DomTreeNode::nextSibling and we keep track of this list's
- // tail in order to append to it. The head of the list if fgFirstBB, by construction.
+ // tail in order to append to it. The head of the list is fgFirstBB, by construction.
BasicBlock* rootListTail = fgFirstBB;
// Traverse the entire block list to build the dominator tree. Skip fgFirstBB
void Begin()
{
unsigned bbArraySize = m_compiler->fgBBNumMax + 1;
- m_compiler->fgDomTreePreOrder = new (m_compiler, CMK_DominatorMemory) unsigned[bbArraySize];
- m_compiler->fgDomTreePostOrder = new (m_compiler, CMK_DominatorMemory) unsigned[bbArraySize];
-
- // Initialize all the data structures.
- for (unsigned i = 0; i < bbArraySize; ++i)
- {
- m_compiler->fgDomTreePreOrder[i] = 0;
- m_compiler->fgDomTreePostOrder[i] = 0;
- }
+ m_compiler->fgDomTreePreOrder = new (m_compiler, CMK_DominatorMemory) unsigned[bbArraySize]{};
+ m_compiler->fgDomTreePostOrder = new (m_compiler, CMK_DominatorMemory) unsigned[bbArraySize]{};
// The preorder and postorder numbers.
// We start from 1 to match the bbNum ordering.