[llvm] [AMDGPU] Update live interval in `convertToThreeAddress` (PR #98781)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 13 17:48:35 PDT 2024


https://github.com/paperchalice created https://github.com/llvm/llvm-project/pull/98781

None

>From c4d1dfa7e84347bf2dbd240200dc6e0c1e03cff8 Mon Sep 17 00:00:00 2001
From: PaperChalice <liujunchang97 at outlook.com>
Date: Sun, 14 Jul 2024 08:47:03 +0800
Subject: [PATCH] [AMDGPU] Update live interval in `convertToThreeAddress`

---
 llvm/lib/Target/AMDGPU/SIInstrInfo.cpp | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
index cc1b9ac0c9ec..2d8b79714e07 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -3952,12 +3952,11 @@ MachineInstr *SIInstrInfo::convertToThreeAddress(MachineInstr &MI,
       Register DefReg = DefMI->getOperand(0).getReg();
       if (!MRI.hasOneNonDBGUse(DefReg))
         return;
-      // We cannot just remove the DefMI here, calling pass will crash.
-      DefMI->setDesc(get(AMDGPU::IMPLICIT_DEF));
-      for (unsigned I = DefMI->getNumOperands() - 1; I != 0; --I)
-        DefMI->removeOperand(I);
       if (LV)
         LV->getVarInfo(DefReg).AliveBlocks.clear();
+      if (LIS)
+        LIS->removeInterval(DefReg);
+      DefMI->eraseFromParent();
     };
 
     int64_t Imm;



More information about the llvm-commits mailing list