From 5f758812b5d8be033023d79c2a71ea752a583dc4 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Mon, 23 Oct 2023 14:49:57 -0700 Subject: [PATCH] JIT: fix bug introduced by recent throw helper block changes `compUsesThrowHelper` indicates codegen will likely need to create a call to a helper, whether or not such calls are shared. In #93371 I didn't appreciate this, and so the JIT was failing to set `compUsesThrowHelper` in cases where a throw helper was going to be needed but throw helper calls were not going to be shared. Fixes #93710. --- src/coreclr/jit/flowgraph.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/coreclr/jit/flowgraph.cpp b/src/coreclr/jit/flowgraph.cpp index 38c04eb9e52563..0bfd3a9971c12a 100644 --- a/src/coreclr/jit/flowgraph.cpp +++ b/src/coreclr/jit/flowgraph.cpp @@ -3538,9 +3538,15 @@ const char* sckName(SpecialCodeKind codeKind) // void Compiler::fgAddCodeRef(BasicBlock* srcBlk, SpecialCodeKind kind) { + // Record that the code will call a THROW_HELPER + // so on Windows Amd64 we can allocate the 4 outgoing + // arg slots on the stack frame if there are no other calls. + // + compUsesThrowHelper = true; + if (!fgUseThrowHelperBlocks() && (kind != SCK_FAIL_FAST)) { - // FailFast will still use a thrwo helper, even in debuggable modes. + // FailFast will still use a common throw helper, even in debuggable modes. // return; } @@ -3549,11 +3555,6 @@ void Compiler::fgAddCodeRef(BasicBlock* srcBlk, SpecialCodeKind kind) unsigned const refData = (kind == SCK_FAIL_FAST) ? 0 : bbThrowIndex(srcBlk); - // Record that the code will call a THROW_HELPER - // so on Windows Amd64 we can allocate the 4 outgoing - // arg slots on the stack frame if there are no other calls. - compUsesThrowHelper = true; - // Look for an existing entry that matches what we're looking for // AddCodeDsc* add = fgFindExcptnTarget(kind, refData);