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
2 changes: 2 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -4633,6 +4633,8 @@ class Compiler

void fgAddFinallyTargetFlags();

void fgFixFinallyTargetFlags(BasicBlock* pred, BasicBlock* succ, BasicBlock* newBlock);

#endif // defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM)
PhaseStatus fgTailMergeThrows();
void fgTailMergeThrowsFallThroughHelper(BasicBlock* predBlock,
Expand Down
8 changes: 8 additions & 0 deletions src/coreclr/jit/fgbasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,10 @@ void Compiler::fgReplaceJumpTarget(BasicBlock* block, BasicBlock* newTarget, Bas
unreached();
break;
}

#if defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM)
fgFixFinallyTargetFlags(block, oldTarget, newTarget);
#endif
}

//------------------------------------------------------------------------
Expand Down Expand Up @@ -4779,6 +4783,10 @@ BasicBlock* Compiler::fgSplitEdge(BasicBlock* curr, BasicBlock* succ)
fgAddRefPred(newBlock, curr);
}

#if defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM)
fgFixFinallyTargetFlags(curr, succ, newBlock);
#endif

// This isn't accurate, but it is complex to compute a reasonable number so just assume that we take the
// branch 50% of the time.
//
Expand Down
26 changes: 26 additions & 0 deletions src/coreclr/jit/fgehopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,32 @@ void Compiler::fgAddFinallyTargetFlags()
}
}

//------------------------------------------------------------------------
// fgFixFinallyTargetFlags: Update BBF_FINALLY_TARGET bits after redirecting flow
//
// Arguments:
// pred - source of flow
// succ - original target of flow from pred
// newSucc - new target of flow from pred
//
void Compiler::fgFixFinallyTargetFlags(BasicBlock* pred, BasicBlock* succ, BasicBlock* newSucc)
{
if (pred->isBBCallAlwaysPairTail())
{
assert(succ->bbFlags & BBF_FINALLY_TARGET);
newSucc->bbFlags |= BBF_FINALLY_TARGET;
succ->bbFlags &= ~BBF_FINALLY_TARGET;

for (BasicBlock* const pred : succ->PredBlocks())
{
if (pred->isBBCallAlwaysPairTail())
{
succ->bbFlags |= BBF_FINALLY_TARGET;
break;
}
}
}
}
#endif // defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM)

//------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/jit/fgprofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,10 @@ void BlockCountInstrumentor::RelocateProbes()
{
m_comp->fgRemoveRefPred(pred, block);
m_comp->fgAddRefPred(intermediary, block);

#if defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM)
m_comp->fgFixFinallyTargetFlags(pred, block, intermediary);
#endif
}
}
}
Expand Down