Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions src/coreclr/src/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4526,6 +4526,23 @@ class AssertionPropFlowCallback
BitVecOps::IntersectionD(apTraits, block->bbAssertionIn, pAssertionOut);
}

//------------------------------------------------------------------------
// MergeHandler: Merge assertions into the first exception handler/filter block.
//
// Arguments:
// block - the block that is the start of a handler or filter;
// firstTryBlock - the first block of the try for "block" handler;
// lastTryBlock - the last block of the try for "block" handler;.
//
// Notes:
// We can jump to the handler from any instruction in the try region.
// It means we can propagate only assertions that are valid for the whole try region.
void MergeHandler(BasicBlock* block, BasicBlock* firstTryBlock, BasicBlock* lastTryBlock)
{
BitVecOps::IntersectionD(apTraits, block->bbAssertionIn, firstTryBlock->bbAssertionIn);
BitVecOps::IntersectionD(apTraits, block->bbAssertionIn, lastTryBlock->bbAssertionOut);
}

// At the end of the merge store results of the dataflow equations, in a postmerge state.
bool EndMerge(BasicBlock* block)
{
Expand Down Expand Up @@ -4677,20 +4694,9 @@ ASSERT_TP* Compiler::optInitAssertionDataflowFlags()

// Initially estimate the OUT sets to everything except killed expressions
// Also set the IN sets to 1, so that we can perform the intersection.
// Also, zero-out the flags for handler blocks, as we could be in the
// handler due to an exception bypassing the regular program flow which
// actually generates assertions along the bbAssertionOut/jumpDestOut
// edges.
for (BasicBlock* block = fgFirstBB; block; block = block->bbNext)
{
if (bbIsHandlerBeg(block))
{
block->bbAssertionIn = BitVecOps::MakeEmpty(apTraits);
}
else
{
block->bbAssertionIn = BitVecOps::MakeCopy(apTraits, apValidFull);
}
block->bbAssertionIn = BitVecOps::MakeCopy(apTraits, apValidFull);
block->bbAssertionGen = BitVecOps::MakeEmpty(apTraits);
block->bbAssertionOut = BitVecOps::MakeCopy(apTraits, apValidFull);
jumpDestOut[block->bbNum] = BitVecOps::MakeCopy(apTraits, apValidFull);
Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/src/jit/dataflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ void DataFlow::ForwardAnalysis(TCallback& callback)
worklist.erase(worklist.begin());

callback.StartMerge(block);
if (m_pCompiler->bbIsHandlerBeg(block))
{
EHblkDsc* ehDsc = m_pCompiler->ehGetBlockHndDsc(block);
callback.MergeHandler(block, ehDsc->ebdTryBeg, ehDsc->ebdTryLast);
}
else
{
flowList* preds = m_pCompiler->BlockPredsWithEH(block);
for (flowList* pred = preds; pred; pred = pred->flNext)
Expand Down
16 changes: 16 additions & 0 deletions src/coreclr/src/jit/optcse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,22 @@ class CSE_DataFlow
#endif // DEBUG
}

//------------------------------------------------------------------------
// MergeHandler: Merge CSE values into the first exception handler/filter block.
//
// Arguments:
// block - the block that is the start of a handler or filter;
// firstTryBlock - the first block of the try for "block" handler;
// lastTryBlock - the last block of the try for "block" handler;.
//
// Notes:
// We can jump to the handler from any instruction in the try region.
// It means we can propagate only CSE that are valid for the whole try region.
void MergeHandler(BasicBlock* block, BasicBlock* firstTryBlock, BasicBlock* lastTryBlock)
{
// TODO CQ: add CSE for handler blocks, CSE_INTO_HANDLERS should be defined.
}

// At the end of the merge store results of the dataflow equations, in a postmerge state.
// We also handle the case where calls conditionally kill CSE availabilty.
//
Expand Down