Skip to content

Commit 92b5d34

Browse files
authored
JIT: Don't allocate string literals inside potential BBJ_THROW candidates (#50112)
1 parent db65d37 commit 92b5d34

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/coreclr/jit/morph.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9590,7 +9590,19 @@ GenTree* Compiler::fgMorphConst(GenTree* tree)
95909590
// guarantee slow performance for that block. Instead cache the return value
95919591
// of CORINFO_HELP_STRCNS and go to cache first giving reasonable perf.
95929592

9593+
bool useLazyStrCns = false;
95939594
if (compCurBB->bbJumpKind == BBJ_THROW)
9595+
{
9596+
useLazyStrCns = true;
9597+
}
9598+
else if (fgGlobalMorph && compCurStmt->GetRootNode()->IsCall())
9599+
{
9600+
// Quick check: if the root node of the current statement happens to be a noreturn call.
9601+
GenTreeCall* call = compCurStmt->GetRootNode()->AsCall();
9602+
useLazyStrCns = call->IsNoReturn() || fgIsThrow(call);
9603+
}
9604+
9605+
if (useLazyStrCns)
95949606
{
95959607
CorInfoHelpFunc helper = info.compCompHnd->getLazyStringLiteralHelper(tree->AsStrCon()->gtScpHnd);
95969608
if (helper != CORINFO_HELP_UNDEF)

0 commit comments

Comments
 (0)