Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT: defer creating throw helper blocks until simple lower #93371

Merged
merged 6 commits into from
Oct 18, 2023
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
4 changes: 4 additions & 0 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5038,6 +5038,10 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
// Insert GC Polls
DoPhase(this, PHASE_INSERT_GC_POLLS, &Compiler::fgInsertGCPolls);

// Create any throw helper blocks that might be needed
//
DoPhase(this, PHASE_CREATE_THROW_HELPERS, &Compiler::fgCreateThrowHelperBlocks);

if (opts.OptimizationEnabled())
{
// Optimize boolean conditions
Expand Down
9 changes: 3 additions & 6 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -6116,12 +6116,11 @@ class Compiler
static unsigned acdHelper(SpecialCodeKind codeKind);

AddCodeDsc* fgAddCodeList;
bool fgAddCodeModf;
bool fgRngChkThrowAdded;
AddCodeDsc* fgExcptnTargetCache[SCK_COUNT];

BasicBlock* fgRngChkTarget(BasicBlock* block, SpecialCodeKind kind);

BasicBlock* fgAddCodeRef(BasicBlock* srcBlk, unsigned refData, SpecialCodeKind kind);
void fgAddCodeRef(BasicBlock* srcBlk, SpecialCodeKind kind);
PhaseStatus fgCreateThrowHelperBlocks();

public:
AddCodeDsc* fgFindExcptnTarget(SpecialCodeKind kind, unsigned refData);
Expand All @@ -6134,8 +6133,6 @@ class Compiler
}

private:
bool fgIsCodeAdded();

bool fgIsThrowHlpBlk(BasicBlock* block);

#if !FEATURE_FIXED_OUT_ARGS
Expand Down
12 changes: 1 addition & 11 deletions src/coreclr/jit/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3069,7 +3069,7 @@ inline Compiler::fgWalkResult Compiler::fgWalkTree(GenTree** pTree,

inline bool Compiler::fgIsThrowHlpBlk(BasicBlock* block)
{
if (!fgIsCodeAdded())
if (!fgRngChkThrowAdded)
{
return false;
}
Expand Down Expand Up @@ -3157,16 +3157,6 @@ inline unsigned Compiler::fgThrowHlpBlkStkLevel(BasicBlock* block)

#endif // !FEATURE_FIXED_OUT_ARGS

/*****************************************************************************
*
* Return true if we've added any new basic blocks.
*/

inline bool Compiler::fgIsCodeAdded()
{
return fgAddCodeModf;
}

/*****************************************************************************
Is the offset too big?
*/
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/compphases.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ CompPhaseNameMacro(PHASE_EXPAND_RTLOOKUPS, "Expand runtime lookups",
CompPhaseNameMacro(PHASE_EXPAND_STATIC_INIT, "Expand static init", false, -1, true)
CompPhaseNameMacro(PHASE_EXPAND_TLS, "Expand TLS access", false, -1, true)
CompPhaseNameMacro(PHASE_INSERT_GC_POLLS, "Insert GC Polls", false, -1, true)
CompPhaseNameMacro(PHASE_CREATE_THROW_HELPERS, "Create throw helper blocks", false, -1, true)
CompPhaseNameMacro(PHASE_DETERMINE_FIRST_COLD_BLOCK, "Determine first cold block", false, -1, true)
CompPhaseNameMacro(PHASE_RATIONALIZE, "Rationalize IR", false, -1, false)
CompPhaseNameMacro(PHASE_SIMPLE_LOWERING, "Do 'simple' lowering", false, -1, false)
Expand Down
4 changes: 3 additions & 1 deletion src/coreclr/jit/fgbasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ void Compiler::fgInit()
// as the code that raises an exception when an array range check fails.

fgAddCodeList = nullptr;
fgAddCodeModf = false;

for (int i = 0; i < SCK_COUNT; i++)
{
Expand All @@ -109,6 +108,9 @@ void Compiler::fgInit()
/* This global flag is set whenever we remove a statement */
fgStmtRemoved = false;

// This global flag is set when we create throw helper blocks
fgRngChkThrowAdded = false;

/* Keep track of whether or not EH statements have been optimized */
fgOptimizedFinally = false;

Expand Down
Loading
Loading