Skip to content

Commit 503cdd1

Browse files
authored
JIT: Merge all RETURN/THROW blocks (#128515)
Fix #128514 `tailMergePreds(nullptr)` was called once, but my understanding is it needs to be called repeatedly as it only processes one set at at time.
1 parent 1358624 commit 503cdd1

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

src/coreclr/jit/fgopt.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5492,13 +5492,21 @@ PhaseStatus Compiler::fgHeadTailMerge(bool early)
54925492
}
54935493
}
54945494

5495-
predInfo.Reset();
5496-
for (BasicBlock* const block : retOrThrowBlocks.BottomUpOrder())
5495+
JITDUMP("Trying tail merge of return and throw blocks\n");
5496+
do
54975497
{
5498-
predInfo.Push(PredInfo(block, block->lastStmt()));
5499-
}
5500-
5501-
tailMergePreds(nullptr);
5498+
predInfo.Reset();
5499+
for (BasicBlock* const block : retOrThrowBlocks.BottomUpOrder())
5500+
{
5501+
// If this block was already merged, skip it
5502+
//
5503+
if (!block->KindIs(BBJ_RETURN, BBJ_THROW))
5504+
{
5505+
continue;
5506+
}
5507+
predInfo.Push(PredInfo(block, block->lastStmt()));
5508+
}
5509+
} while (tailMergePreds(nullptr));
55025510

55035511
// Work through any retries
55045512
//

src/coreclr/jit/jitstd/vector.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,13 +613,15 @@ vector<T, Allocator>& vector<T, Allocator>::operator=(vector<T, Allocator>&& vec
613613
template <typename T, typename Allocator>
614614
typename vector<T, Allocator>::reference vector<T, Allocator>::operator[](size_type n)
615615
{
616+
assert(n >= 0 && n < m_nSize);
616617
return m_pArray[n];
617618
}
618619

619620
template <typename T, typename Allocator>
620621
typename vector<T, Allocator>::const_reference
621622
vector<T, Allocator>::operator[](size_type n) const
622623
{
624+
assert(n >= 0 && n < m_nSize);
623625
return m_pArray[n];
624626
}
625627

0 commit comments

Comments
 (0)