[flang-commits] [flang] [flang][FIR][Mem2Reg] Add supoort for FIR. (PR #172808)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Thu Dec 18 08:06:35 PST 2025


================
@@ -2861,6 +2888,40 @@ llvm::SmallVector<mlir::Attribute> fir::LenParamIndexOp::getAttributes() {
 // LoadOp
 //===----------------------------------------------------------------------===//
 
+bool fir::LoadOp::loadsFrom(const mlir::MemorySlot &slot) {
+  return getMemref() == slot.ptr;
+}
+
+bool fir::LoadOp::storesTo(const mlir::MemorySlot &slot) { return false; }
+
+mlir::Value fir::LoadOp::getStored(const mlir::MemorySlot &slot,
+                                   mlir::OpBuilder &builder,
+                                   mlir::Value reachingDef,
+                                   const mlir::DataLayout &dataLayout) {
+  llvm_unreachable("getStored should not be called on LoadOp");
----------------
tblah wrote:

The documentation for this interface method recommends returning a null value if the operation does not store to the slot.

https://github.com/llvm/llvm-project/pull/172808


More information about the flang-commits mailing list