From 91f3905f5ec75e51ac0fff3734fabeb69111ee6c Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Mon, 16 Feb 2026 17:30:37 +0100 Subject: [PATCH 1/4] JIT: Handle LCL_ADDR in TreeLifeUpdater --- src/coreclr/jit/treelifeupdater.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/coreclr/jit/treelifeupdater.cpp b/src/coreclr/jit/treelifeupdater.cpp index bf0254c5b77e74..bed42e125e95ff 100644 --- a/src/coreclr/jit/treelifeupdater.cpp +++ b/src/coreclr/jit/treelifeupdater.cpp @@ -311,6 +311,10 @@ void TreeLifeUpdater::UpdateLife(GenTree* tree) }; tree->VisitLocalDefNodes(m_compiler, visitDef); } + else if (tree->OperIs(GT_LCL_ADDR)) + { + UpdateLifeVar(tree, tree->AsLclVarCommon()); + } } //------------------------------------------------------------------------ From 564177f5c0a15f74c5abaa980cac8b185c92a459 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Mon, 16 Feb 2026 18:34:10 +0100 Subject: [PATCH 2/4] Only handle them for async TreeLifeUpdater --- src/coreclr/jit/async.cpp | 2 +- src/coreclr/jit/codegencommon.cpp | 2 +- src/coreclr/jit/copyprop.cpp | 2 +- src/coreclr/jit/treelifeupdater.cpp | 6 +++++- src/coreclr/jit/treelifeupdater.h | 1 + 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/coreclr/jit/async.cpp b/src/coreclr/jit/async.cpp index c900d83ee79106..75cf14043b16ba 100644 --- a/src/coreclr/jit/async.cpp +++ b/src/coreclr/jit/async.cpp @@ -469,7 +469,7 @@ void AsyncLiveness::StartBlock(BasicBlock* block) // void AsyncLiveness::Update(GenTree* node) { - m_updater.UpdateLife(node); + m_updater.UpdateLife(node); } //------------------------------------------------------------------------ diff --git a/src/coreclr/jit/codegencommon.cpp b/src/coreclr/jit/codegencommon.cpp index bfd6804cb6f00e..040a2c980f6cb6 100644 --- a/src/coreclr/jit/codegencommon.cpp +++ b/src/coreclr/jit/codegencommon.cpp @@ -591,7 +591,7 @@ void CodeGen::genMarkLabelsForCodegen() void CodeGenInterface::genUpdateLife(GenTree* tree) { - treeLifeUpdater->UpdateLife(tree); + treeLifeUpdater->UpdateLife(tree); } void CodeGenInterface::genUpdateLife(VARSET_VALARG_TP newLife) diff --git a/src/coreclr/jit/copyprop.cpp b/src/coreclr/jit/copyprop.cpp index 22ebf6a8791346..61a2b71d78a719 100644 --- a/src/coreclr/jit/copyprop.cpp +++ b/src/coreclr/jit/copyprop.cpp @@ -404,7 +404,7 @@ bool Compiler::optBlockCopyProp(BasicBlock* block, LclNumToLiveDefsMap* curSsaNa // SSA renaming process. for (GenTree* const tree : stmt->TreeList()) { - treeLifeUpdater.UpdateLife(tree); + treeLifeUpdater.UpdateLife(tree); if (tree->OperIsSsaDef()) { diff --git a/src/coreclr/jit/treelifeupdater.cpp b/src/coreclr/jit/treelifeupdater.cpp index bed42e125e95ff..43f523a429330f 100644 --- a/src/coreclr/jit/treelifeupdater.cpp +++ b/src/coreclr/jit/treelifeupdater.cpp @@ -285,6 +285,7 @@ void TreeLifeUpdater::UpdateLifeVar(GenTree* tree, GenTreeLclVarComm // tree - the tree which effect on liveness is processed. // template +template void TreeLifeUpdater::UpdateLife(GenTree* tree) { assert(m_compiler->GetCurLVEpoch() == epoch); @@ -311,7 +312,7 @@ void TreeLifeUpdater::UpdateLife(GenTree* tree) }; tree->VisitLocalDefNodes(m_compiler, visitDef); } - else if (tree->OperIs(GT_LCL_ADDR)) + else if (ProcessLclAddrs && tree->OperIs(GT_LCL_ADDR)) { UpdateLifeVar(tree, tree->AsLclVarCommon()); } @@ -409,3 +410,6 @@ void TreeLifeUpdater::DumpLifeDelta(GenTree* tree) template class TreeLifeUpdater; template class TreeLifeUpdater; +template void TreeLifeUpdater::UpdateLife(GenTree*); +template void TreeLifeUpdater::UpdateLife(GenTree*); +template void TreeLifeUpdater::UpdateLife(GenTree*); diff --git a/src/coreclr/jit/treelifeupdater.h b/src/coreclr/jit/treelifeupdater.h index 021ec00169f48f..d9f6d000f73b61 100644 --- a/src/coreclr/jit/treelifeupdater.h +++ b/src/coreclr/jit/treelifeupdater.h @@ -13,6 +13,7 @@ class TreeLifeUpdater { public: TreeLifeUpdater(Compiler* compiler); + template void UpdateLife(GenTree* tree); bool UpdateLifeFieldVar(GenTreeLclVar* lclNode, unsigned multiRegIndex); From 49ee960ca544ee2fae1d1241dcf1187b698b040c Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Mon, 16 Feb 2026 18:55:54 +0100 Subject: [PATCH 3/4] Run jit-format --- src/coreclr/jit/treelifeupdater.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/jit/treelifeupdater.h b/src/coreclr/jit/treelifeupdater.h index d9f6d000f73b61..10e3d8454ea65b 100644 --- a/src/coreclr/jit/treelifeupdater.h +++ b/src/coreclr/jit/treelifeupdater.h @@ -13,7 +13,7 @@ class TreeLifeUpdater { public: TreeLifeUpdater(Compiler* compiler); - template + template void UpdateLife(GenTree* tree); bool UpdateLifeFieldVar(GenTreeLclVar* lclNode, unsigned multiRegIndex); From e02c74c786b1af93024d6e3d299ff26ab17a572b Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Tue, 17 Feb 2026 20:14:37 +0100 Subject: [PATCH 4/4] Feedback --- src/coreclr/jit/treelifeupdater.cpp | 6 +++--- src/coreclr/jit/treelifeupdater.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/coreclr/jit/treelifeupdater.cpp b/src/coreclr/jit/treelifeupdater.cpp index 43f523a429330f..1d414bb9b5d090 100644 --- a/src/coreclr/jit/treelifeupdater.cpp +++ b/src/coreclr/jit/treelifeupdater.cpp @@ -285,7 +285,7 @@ void TreeLifeUpdater::UpdateLifeVar(GenTree* tree, GenTreeLclVarComm // tree - the tree which effect on liveness is processed. // template -template +template void TreeLifeUpdater::UpdateLife(GenTree* tree) { assert(m_compiler->GetCurLVEpoch() == epoch); @@ -300,7 +300,7 @@ void TreeLifeUpdater::UpdateLife(GenTree* tree) { UpdateLifeVar(tree, tree->AsLclVarCommon()); } - else if (tree->OperIsIndir() && tree->AsIndir()->Addr()->OperIs(GT_LCL_ADDR)) + else if (!GeneralLclAddrHandling && tree->OperIsIndir() && tree->AsIndir()->Addr()->OperIs(GT_LCL_ADDR)) { UpdateLifeVar(tree, tree->AsIndir()->Addr()->AsLclVarCommon()); } @@ -312,7 +312,7 @@ void TreeLifeUpdater::UpdateLife(GenTree* tree) }; tree->VisitLocalDefNodes(m_compiler, visitDef); } - else if (ProcessLclAddrs && tree->OperIs(GT_LCL_ADDR)) + else if (GeneralLclAddrHandling && tree->OperIs(GT_LCL_ADDR)) { UpdateLifeVar(tree, tree->AsLclVarCommon()); } diff --git a/src/coreclr/jit/treelifeupdater.h b/src/coreclr/jit/treelifeupdater.h index 10e3d8454ea65b..1bef0d832d2673 100644 --- a/src/coreclr/jit/treelifeupdater.h +++ b/src/coreclr/jit/treelifeupdater.h @@ -13,7 +13,7 @@ class TreeLifeUpdater { public: TreeLifeUpdater(Compiler* compiler); - template + template void UpdateLife(GenTree* tree); bool UpdateLifeFieldVar(GenTreeLclVar* lclNode, unsigned multiRegIndex);