[llvm] 811759b - [AVR] Disable post increment load from program memory space

Ben Shi via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 11 21:00:12 PDT 2023


Author: Ben Shi
Date: 2023-04-12T11:52:55+08:00
New Revision: 811759b1009b70051e5314a9274afe3d788b99ed

URL: https://github.com/llvm/llvm-project/commit/811759b1009b70051e5314a9274afe3d788b99ed
DIFF: https://github.com/llvm/llvm-project/commit/811759b1009b70051e5314a9274afe3d788b99ed.diff

LOG: [AVR] Disable post increment load from program memory space

We temporarily only allow post increment load/store from/to data memory,
and disable post increment load from program space.

Updates https://github.com/llvm/llvm-project/issues/59914

Reviewed By: mzh

Differential Revision: https://reviews.llvm.org/D147761

Added: 
    

Modified: 
    llvm/lib/Target/AVR/AVRISelLowering.cpp
    llvm/test/CodeGen/AVR/load.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AVR/AVRISelLowering.cpp b/llvm/lib/Target/AVR/AVRISelLowering.cpp
index 0c8eb30df0c82..3b812750cebc0 100644
--- a/llvm/lib/Target/AVR/AVRISelLowering.cpp
+++ b/llvm/lib/Target/AVR/AVRISelLowering.cpp
@@ -1151,6 +1151,12 @@ bool AVRTargetLowering::getPostIndexedAddressParts(SDNode *N, SDNode *Op,
       return false;
     }
 
+    // FIXME: We temporarily disable post increment load from program memory,
+    //        due to bug https://github.com/llvm/llvm-project/issues/59914.
+    if (const LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
+      if (AVR::isProgramMemoryAccess(LD))
+        return false;
+
     Base = Op->getOperand(0);
     Offset = DAG.getConstant(RHSC, DL, MVT::i8);
     AM = ISD::POST_INC;

diff  --git a/llvm/test/CodeGen/AVR/load.ll b/llvm/test/CodeGen/AVR/load.ll
index 53748b3b100b9..efc7549adb651 100644
--- a/llvm/test/CodeGen/AVR/load.ll
+++ b/llvm/test/CodeGen/AVR/load.ll
@@ -140,3 +140,18 @@ while.end:                                        ; preds = %while.body, %entry
   %r.0.lcssa = phi i16 [ 0, %entry ], [ %add, %while.body ]
   ret i16 %r.0.lcssa
 }
+
+define ptr addrspace(1) @load16_postinc_progmem(ptr addrspace(1) readonly %0) {
+; CHECK-LABEL: load16_postinc_progmem:
+; CHECK:         movw r30, [[REG0:r[0-9]+]]
+; CHECK:         lpm  [[REG1:r[0-9]+]], Z+
+; CHECK:         lpm  [[REG1:r[0-9]+]], Z
+; CHECK:         call foo
+; CHECK:         adiw [[REG0:r[0-9]+]], 2
+  %2 = load i16, ptr addrspace(1) %0, align 1
+  tail call addrspace(1) void @foo(i16 %2)
+  %3 = getelementptr inbounds i16, ptr addrspace(1) %0, i16 1
+  ret ptr addrspace(1) %3
+}
+
+declare void @foo(i16)


        


More information about the llvm-commits mailing list