From db4c631f07e816493a8d767c2dffefde5239f452 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Tue, 26 Feb 2019 11:39:46 -0800 Subject: [PATCH] JIT: In morph, only call DefinesLocal on assignments (dotnet/coreclr#22753) When checking for local assertions to kill in morph, only call `DefinesLocal` on `GT_ASG` nodes. Also, assert that we never see LIR style assignments. Resolves dotnet/coreclr#22747. Commit migrated from https://github.com/dotnet/coreclr/commit/56697257c4e24aa24a64b70eb4ce07d91882005b --- src/coreclr/src/jit/morph.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/coreclr/src/jit/morph.cpp b/src/coreclr/src/jit/morph.cpp index ff9320ab..f3556ad 100644 --- a/src/coreclr/src/jit/morph.cpp +++ b/src/coreclr/src/jit/morph.cpp @@ -15184,7 +15184,16 @@ void Compiler::fgMorphTreeDone(GenTree* tree, { /* Is this an assignment to a local variable */ GenTreeLclVarCommon* lclVarTree = nullptr; - if (tree->DefinesLocal(this, &lclVarTree)) + + // The check below will miss LIR-style assignments. + // + // But we shouldn't be running local assertion prop on these, + // as local prop gets disabled when we run global prop. + assert(!tree->OperIs(GT_STORE_LCL_VAR, GT_STORE_LCL_FLD)); + + // DefinesLocal can return true for some BLK op uses, so + // check what gets assigned only when we're at an assignment. + if (tree->OperIs(GT_ASG) && tree->DefinesLocal(this, &lclVarTree)) { unsigned lclNum = lclVarTree->gtLclNum; noway_assert(lclNum < lvaCount); -- 2.7.4