[llvm] [RISCV] Don't create MachineMemOperand in foldMemoryOperandImpl. (PR #109840)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 24 10:55:21 PDT 2024


https://github.com/topperc created https://github.com/llvm/llvm-project/pull/109840

The caller already does this after we return. I think it will overwrite any MMO we add.

I'm the original author of this code and I'm not sure why I did it.

>From b4fd3624682abc79cb8add7b5cac82a25e9a9b06 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Tue, 24 Sep 2024 10:36:46 -0700
Subject: [PATCH] [RISCV] Don't create MachineMemOperand in
 foldMemoryOperandImpl.

The caller already does this after we return. I think it will
overwrite any MMO we add.

I'm the original author of this code and I'm not sure why I did it.
---
 llvm/lib/Target/RISCV/RISCVInstrInfo.cpp | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
index 41f93fde17d329..b594531ccb0958 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -736,8 +736,6 @@ MachineInstr *RISCVInstrInfo::foldMemoryOperandImpl(
     MachineFunction &MF, MachineInstr &MI, ArrayRef<unsigned> Ops,
     MachineBasicBlock::iterator InsertPt, int FrameIndex, LiveIntervals *LIS,
     VirtRegMap *VRM) const {
-  const MachineFrameInfo &MFI = MF.getFrameInfo();
-
   // The below optimizations narrow the load so they are only valid for little
   // endian.
   // TODO: Support big endian by adding an offset into the frame object?
@@ -776,17 +774,11 @@ MachineInstr *RISCVInstrInfo::foldMemoryOperandImpl(
     break;
   }
 
-  MachineMemOperand *MMO = MF.getMachineMemOperand(
-      MachinePointerInfo::getFixedStack(MF, FrameIndex),
-      MachineMemOperand::MOLoad, MFI.getObjectSize(FrameIndex),
-      MFI.getObjectAlign(FrameIndex));
-
   Register DstReg = MI.getOperand(0).getReg();
   return BuildMI(*MI.getParent(), InsertPt, MI.getDebugLoc(), get(LoadOpc),
                  DstReg)
       .addFrameIndex(FrameIndex)
-      .addImm(0)
-      .addMemOperand(MMO);
+      .addImm(0);
 }
 
 void RISCVInstrInfo::movImm(MachineBasicBlock &MBB,



More information about the llvm-commits mailing list