Skip to content

Commit 103fa2c

Browse files
authored
JIT: fix recursive inline checking (#35020)
We were not setting `m_Code` in the root inline context, and so were sometimes allowing one level of recursive inlining.
1 parent 7e73931 commit 103fa2c

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/coreclr/src/jit/flowgraph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21896,7 +21896,7 @@ unsigned Compiler::fgCheckInlineDepthAndRecursion(InlineInfo* inlineInfo)
2189621896

2189721897
for (; inlineContext != nullptr; inlineContext = inlineContext->GetParent())
2189821898
{
21899-
21899+
assert(inlineContext->GetCode() != nullptr);
2190021900
depth++;
2190121901

2190221902
if (inlineContext->GetCode() == candidateCode)

src/coreclr/src/jit/inline.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,7 @@ InlineContext* InlineStrategy::NewRoot()
11711171
InlineContext* rootContext = new (m_Compiler, CMK_Inlining) InlineContext(this);
11721172

11731173
rootContext->m_ILSize = m_Compiler->info.compILCodeSize;
1174+
rootContext->m_Code = m_Compiler->info.compCode;
11741175

11751176
#if defined(DEBUG) || defined(INLINE_DATA)
11761177

src/coreclr/src/jit/inline.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ class InlineContext
662662
}
663663

664664
// Get the code pointer for this context.
665-
BYTE* GetCode() const
665+
const BYTE* GetCode() const
666666
{
667667
return m_Code;
668668
}
@@ -731,7 +731,7 @@ class InlineContext
731731
InlineContext* m_Parent; // logical caller (parent)
732732
InlineContext* m_Child; // first child
733733
InlineContext* m_Sibling; // next child of the parent
734-
BYTE* m_Code; // address of IL buffer for the method
734+
const BYTE* m_Code; // address of IL buffer for the method
735735
unsigned m_ILSize; // size of IL buffer for the method
736736
unsigned m_ImportedILSize; // estimated size of imported IL
737737
IL_OFFSETX m_Offset; // call site location within parent

0 commit comments

Comments
 (0)