[llvm] Try to derive registerinfo if registerinfo is null (PR #82651)

via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 22 09:01:05 PST 2024


https://github.com/AtariDreams updated https://github.com/llvm/llvm-project/pull/82651

>From bee086c3ef179a826831f51a7eb8e830159096c2 Mon Sep 17 00:00:00 2001
From: Rose <83477269+AtariDreams at users.noreply.github.com>
Date: Thu, 22 Feb 2024 11:44:43 -0500
Subject: [PATCH] Try to derive registerinfo if registerinfo is nullptr

---
 llvm/lib/CodeGen/MachineInstr.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp
index efbcc839f22d0c..3cd6c5c11c824c 100644
--- a/llvm/lib/CodeGen/MachineInstr.cpp
+++ b/llvm/lib/CodeGen/MachineInstr.cpp
@@ -1013,6 +1013,8 @@ bool MachineInstr::hasRegisterImplicitUseOperand(Register Reg) const {
 /// the search criteria to a use that kills the register if isKill is true.
 int MachineInstr::findRegisterUseOperandIdx(
     Register Reg, bool isKill, const TargetRegisterInfo *TRI) const {
+  if (!TRI)
+    TRI = getParent() ? getMF()->getSubtarget().getRegisterInfo() : nullptr;
   for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
     const MachineOperand &MO = getOperand(i);
     if (!MO.isReg() || !MO.isUse())
@@ -1063,6 +1065,8 @@ int
 MachineInstr::findRegisterDefOperandIdx(Register Reg, bool isDead, bool Overlap,
                                         const TargetRegisterInfo *TRI) const {
   bool isPhys = Reg.isPhysical();
+  if (!TRI)
+    TRI = getParent() ? getMF()->getSubtarget().getRegisterInfo() : nullptr;
   for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
     const MachineOperand &MO = getOperand(i);
     // Accept regmask operands when Overlap is set.



More information about the llvm-commits mailing list