summaryrefslogtreecommitdiff
path: root/src/jit/flowgraph.cpp
diff options
context:
space:
mode:
authorWes Haggard <weshaggard@users.noreply.github.com>2018-03-30 11:59:39 -0700
committerGitHub <noreply@github.com>2018-03-30 11:59:39 -0700
commitf5720eea7e7ada0bc0f6ba05a3825c73871a8b81 (patch)
treea43d3016ce6dbe8024d171bd4dd9b9a90c3684c9 /src/jit/flowgraph.cpp
parentd845ef1c33f0283d18541714ad9469a7b1a559e6 (diff)
parent3365ac5efe5d6a7ea965ed1d17a5dd5474a033a5 (diff)
downloadcoreclr-f5720eea7e7ada0bc0f6ba05a3825c73871a8b81.tar.gz
coreclr-f5720eea7e7ada0bc0f6ba05a3825c73871a8b81.tar.bz2
coreclr-f5720eea7e7ada0bc0f6ba05a3825c73871a8b81.zip
Merge pull request #17347 from weshaggard/MergeMaster21
[release/2.1] Merge master to release/2.1
Diffstat (limited to 'src/jit/flowgraph.cpp')
-rw-r--r--src/jit/flowgraph.cpp50
1 files changed, 31 insertions, 19 deletions
diff --git a/src/jit/flowgraph.cpp b/src/jit/flowgraph.cpp
index b1a4fef8e2..68e67ca018 100644
--- a/src/jit/flowgraph.cpp
+++ b/src/jit/flowgraph.cpp
@@ -261,7 +261,7 @@ void Compiler::fgInstrumentMethod()
int countOfBlocks = 0;
BasicBlock* block;
- for (block = fgFirstBB; block; block = block->bbNext)
+ for (block = fgFirstBB; (block != nullptr); block = block->bbNext)
{
if (!(block->bbFlags & BBF_IMPORTED) || (block->bbFlags & BBF_INTERNAL))
{
@@ -272,11 +272,9 @@ void Compiler::fgInstrumentMethod()
// Allocate the profile buffer
- ICorJitInfo::ProfileBuffer* bbProfileBuffer;
-
- HRESULT res = info.compCompHnd->allocBBProfileBuffer(countOfBlocks, &bbProfileBuffer);
+ ICorJitInfo::ProfileBuffer* bbProfileBufferStart;
- ICorJitInfo::ProfileBuffer* bbProfileBufferStart = bbProfileBuffer;
+ HRESULT res = info.compCompHnd->allocBBProfileBuffer(countOfBlocks, &bbProfileBufferStart);
GenTree* stmt;
@@ -300,9 +298,16 @@ void Compiler::fgInstrumentMethod()
}
else
{
- // Assign a buffer entry for each basic block
+ // For each BasicBlock (non-Internal)
+ // 1. Assign the blocks bbCodeOffs to the ILOffset field of this blocks profile data.
+ // 2. Add an operation that increments the ExecutionCount field at the beginning of the block.
- for (block = fgFirstBB; block; block = block->bbNext)
+ // Each (non-Internal) block has it own ProfileBuffer tuple [ILOffset, ExecutionCount]
+ // To start we initialize our current one with the first one that we allocated
+ //
+ ICorJitInfo::ProfileBuffer* bbCurrentBlockProfileBuffer = bbProfileBufferStart;
+
+ for (block = fgFirstBB; (block != nullptr); block = block->bbNext)
{
if (!(block->bbFlags & BBF_IMPORTED) || (block->bbFlags & BBF_INTERNAL))
{
@@ -310,25 +315,31 @@ void Compiler::fgInstrumentMethod()
}
// Assign the current block's IL offset into the profile data
- bbProfileBuffer->ILOffset = block->bbCodeOffs;
+ bbCurrentBlockProfileBuffer->ILOffset = block->bbCodeOffs;
+ assert(bbCurrentBlockProfileBuffer->ExecutionCount == 0); // This value should already be zero-ed out
- size_t addrOfBlockCount = (size_t)&bbProfileBuffer->ExecutionCount;
+ size_t addrOfCurrentExecutionCount = (size_t)&bbCurrentBlockProfileBuffer->ExecutionCount;
// Read Basic-Block count value
- GenTree* valueNode = gtNewIndOfIconHandleNode(TYP_INT, addrOfBlockCount, GTF_ICON_BBC_PTR, false);
+ GenTree* valueNode =
+ gtNewIndOfIconHandleNode(TYP_INT, addrOfCurrentExecutionCount, GTF_ICON_BBC_PTR, false);
// Increment value by 1
GenTree* rhsNode = gtNewOperNode(GT_ADD, TYP_INT, valueNode, gtNewIconNode(1));
// Write new Basic-Block count value
- GenTree* lhsNode = gtNewIndOfIconHandleNode(TYP_INT, addrOfBlockCount, GTF_ICON_BBC_PTR, false);
+ GenTree* lhsNode = gtNewIndOfIconHandleNode(TYP_INT, addrOfCurrentExecutionCount, GTF_ICON_BBC_PTR, false);
GenTree* asgNode = gtNewAssignNode(lhsNode, rhsNode);
fgInsertStmtAtBeg(block, asgNode);
+ // Advance to the next ProfileBuffer tuple [ILOffset, ExecutionCount]
+ bbCurrentBlockProfileBuffer++;
+
+ // One less block
countOfBlocks--;
- bbProfileBuffer++;
}
+ // Check that we allocated and initialized the same number of ProfileBuffer tuples
noway_assert(countOfBlocks == 0);
// Add the method entry callback node
@@ -359,10 +370,11 @@ void Compiler::fgInstrumentMethod()
GenTreeArgList* args = gtNewArgList(arg);
GenTree* call = gtNewHelperCallNode(CORINFO_HELP_BBT_FCN_ENTER, TYP_VOID, args);
- size_t addrOfBlockCount = (size_t)&bbProfileBuffer->ExecutionCount;
+ // Get the address of the first blocks ExecutionCount
+ size_t addrOfFirstExecutionCount = (size_t)&bbProfileBufferStart->ExecutionCount;
// Read Basic-Block count value
- GenTree* valueNode = gtNewIndOfIconHandleNode(TYP_INT, addrOfBlockCount, GTF_ICON_BBC_PTR, false);
+ GenTree* valueNode = gtNewIndOfIconHandleNode(TYP_INT, addrOfFirstExecutionCount, GTF_ICON_BBC_PTR, false);
// Compare Basic-Block count value against zero
GenTree* relop = gtNewOperNode(GT_NE, TYP_INT, valueNode, gtNewIconNode(0, TYP_INT));
@@ -7456,7 +7468,7 @@ GenTree* Compiler::fgDoNormalizeOnStore(GenTree* tree)
if (fgCastNeeded(op2, varDsc->TypeGet()))
{
- op2 = gtNewCastNode(TYP_INT, op2, varDsc->TypeGet());
+ op2 = gtNewCastNode(TYP_INT, op2, false, varDsc->TypeGet());
tree->gtOp.gtOp2 = op2;
// Propagate GTF_COLON_COND
@@ -20680,12 +20692,12 @@ Compiler::fgWalkResult Compiler::fgStress64RsltMulCB(GenTree** pTree, fgWalkData
#endif // DEBUG
// To ensure optNarrowTree() doesn't fold back to the original tree.
- tree->gtOp.gtOp1 = pComp->gtNewCastNode(TYP_LONG, tree->gtOp.gtOp1, TYP_LONG);
+ tree->gtOp.gtOp1 = pComp->gtNewCastNode(TYP_LONG, tree->gtOp.gtOp1, false, TYP_LONG);
tree->gtOp.gtOp1 = pComp->gtNewOperNode(GT_NOP, TYP_LONG, tree->gtOp.gtOp1);
- tree->gtOp.gtOp1 = pComp->gtNewCastNode(TYP_LONG, tree->gtOp.gtOp1, TYP_LONG);
- tree->gtOp.gtOp2 = pComp->gtNewCastNode(TYP_LONG, tree->gtOp.gtOp2, TYP_LONG);
+ tree->gtOp.gtOp1 = pComp->gtNewCastNode(TYP_LONG, tree->gtOp.gtOp1, false, TYP_LONG);
+ tree->gtOp.gtOp2 = pComp->gtNewCastNode(TYP_LONG, tree->gtOp.gtOp2, false, TYP_LONG);
tree->gtType = TYP_LONG;
- *pTree = pComp->gtNewCastNode(TYP_INT, tree, TYP_INT);
+ *pTree = pComp->gtNewCastNode(TYP_INT, tree, false, TYP_INT);
#ifdef DEBUG
if (pComp->verbose)