Fix copy propagation (#66070)
authorSingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
Thu, 3 Mar 2022 22:59:13 +0000 (01:59 +0300)
committerGitHub <noreply@github.com>
Thu, 3 Mar 2022 22:59:13 +0000 (14:59 -0800)
Now that we don't push defs for shadowed parameters, we don't want to pop them as well.

src/coreclr/jit/copyprop.cpp

index 991c658..bfc6d04 100644 (file)
@@ -43,11 +43,13 @@ void Compiler::optBlockCopyPropPopStacks(BasicBlock* block, LclNumToLiveDefsMap*
                 }
 
                 CopyPropSsaDefStack* stack = nullptr;
-                curSsaName->Lookup(lclNum, &stack);
-                stack->Pop();
-                if (stack->Empty())
+                if (curSsaName->Lookup(lclNum, &stack))
                 {
-                    curSsaName->Remove(lclNum);
+                    stack->Pop();
+                    if (stack->Empty())
+                    {
+                        curSsaName->Remove(lclNum);
+                    }
                 }
             }
         }