From c71cd27c98f1007e462259522217797e9923db32 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Mon, 6 Jan 2025 19:39:45 +0100 Subject: [PATCH] JIT: Check DFS tree containment before checking ancestry Fix #110957 --- src/coreclr/jit/optimizer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/jit/optimizer.cpp b/src/coreclr/jit/optimizer.cpp index e12a377e2c1f8..fbd05f5e8ea40 100644 --- a/src/coreclr/jit/optimizer.cpp +++ b/src/coreclr/jit/optimizer.cpp @@ -5730,7 +5730,7 @@ void Compiler::optRemoveRedundantZeroInits() predEdge = predEdge->getNextPredEdge()) { BasicBlock* const predBlock = predEdge->getSourceBlock(); - if (m_dfsTree->IsAncestor(block, predBlock)) + if (m_dfsTree->Contains(predBlock) && m_dfsTree->IsAncestor(block, predBlock)) { JITDUMP(FMT_BB " is part of a cycle, stopping the block scan\n", block->bbNum); stop = true;