From b6b326636ee44cf8ce0c4db34edffc255979f344 Mon Sep 17 00:00:00 2001 From: Quan Anh Mai Date: Sat, 13 Dec 2025 17:07:41 +0700 Subject: [PATCH] Take into consideration dead paths --- src/hotspot/share/opto/memnode.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/opto/memnode.cpp b/src/hotspot/share/opto/memnode.cpp index 533c59b9baf..6d729f86c23 100644 --- a/src/hotspot/share/opto/memnode.cpp +++ b/src/hotspot/share/opto/memnode.cpp @@ -121,7 +121,7 @@ bool MemNode::check_not_escaped(PhaseValues* phase, Unique_Node_List& aliases, A } // Find all control nodes from ctl to alloc, alloc must dominate ctl, which means all paths from - // ctl must arrive at alloc + // ctl must arrive at alloc, or a dead end ResourceMark rm; Unique_Node_List controls; controls.push(ctl); @@ -147,6 +147,11 @@ bool MemNode::check_not_escaped(PhaseValues* phase, Unique_Node_List& aliases, A } } + if (!controls.member(alloc)) { + // If there is no control path from ctl to alloc, ctl is a dead path, give up + return false; + } + // Find all nodes that may escape alloc, and see whether they may be between ctl and alloc for (uint idx = 0; idx < aliases.size(); idx++) { Node* n = aliases.at(idx);