Skip to content

Commit 811759b

Browse files
committed
[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 #59914 Reviewed By: mzh Differential Revision: https://reviews.llvm.org/D147761
1 parent 9d4df97 commit 811759b

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

llvm/lib/Target/AVR/AVRISelLowering.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,12 @@ bool AVRTargetLowering::getPostIndexedAddressParts(SDNode *N, SDNode *Op,
11511151
return false;
11521152
}
11531153

1154+
// FIXME: We temporarily disable post increment load from program memory,
1155+
// due to bug https://github.com/llvm/llvm-project/issues/59914.
1156+
if (const LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
1157+
if (AVR::isProgramMemoryAccess(LD))
1158+
return false;
1159+
11541160
Base = Op->getOperand(0);
11551161
Offset = DAG.getConstant(RHSC, DL, MVT::i8);
11561162
AM = ISD::POST_INC;

llvm/test/CodeGen/AVR/load.ll

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,18 @@ while.end: ; preds = %while.body, %entry
140140
%r.0.lcssa = phi i16 [ 0, %entry ], [ %add, %while.body ]
141141
ret i16 %r.0.lcssa
142142
}
143+
144+
define ptr addrspace(1) @load16_postinc_progmem(ptr addrspace(1) readonly %0) {
145+
; CHECK-LABEL: load16_postinc_progmem:
146+
; CHECK: movw r30, [[REG0:r[0-9]+]]
147+
; CHECK: lpm [[REG1:r[0-9]+]], Z+
148+
; CHECK: lpm [[REG1:r[0-9]+]], Z
149+
; CHECK: call foo
150+
; CHECK: adiw [[REG0:r[0-9]+]], 2
151+
%2 = load i16, ptr addrspace(1) %0, align 1
152+
tail call addrspace(1) void @foo(i16 %2)
153+
%3 = getelementptr inbounds i16, ptr addrspace(1) %0, i16 1
154+
ret ptr addrspace(1) %3
155+
}
156+
157+
declare void @foo(i16)

0 commit comments

Comments
 (0)