[llvm] [CodeGen][NFC] Guard copy propogation in machine CSE against undefs (PR #97413)

Vikram Hegde via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 2 05:59:22 PDT 2024


https://github.com/vikramRH created https://github.com/llvm/llvm-project/pull/97413

None

>From 241210f51572df97a394f9dac5372bf7cf54c951 Mon Sep 17 00:00:00 2001
From: Vikram <Vikram.Hegde at amd.com>
Date: Tue, 2 Jul 2024 08:47:00 -0400
Subject: [PATCH] [CodeGen][NFC] Guard copy propogation in machine CSE against
 undefs

---
 llvm/lib/CodeGen/MachineCSE.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/CodeGen/MachineCSE.cpp b/llvm/lib/CodeGen/MachineCSE.cpp
index 4e6101f875589..e39aae56bf116 100644
--- a/llvm/lib/CodeGen/MachineCSE.cpp
+++ b/llvm/lib/CodeGen/MachineCSE.cpp
@@ -184,7 +184,7 @@ bool MachineCSE::PerformTrivialCopyPropagation(MachineInstr *MI,
       continue;
     bool OnlyOneUse = MRI->hasOneNonDBGUse(Reg);
     MachineInstr *DefMI = MRI->getVRegDef(Reg);
-    if (!DefMI->isCopy())
+    if (!DefMI || !DefMI->isCopy())
       continue;
     Register SrcReg = DefMI->getOperand(1).getReg();
     if (!SrcReg.isVirtual())



More information about the llvm-commits mailing list