[llvm] r301893 - [AVR] Save/restore the frame pointer for all functions
Dylan McKay via llvm-commits
llvm-commits at lists.llvm.org
Mon May 1 18:57:49 PDT 2017
Author: dylanmckay
Date: Mon May 1 20:57:48 2017
New Revision: 301893
URL: http://llvm.org/viewvc/llvm-project?rev=301893&view=rev
Log:
[AVR] Save/restore the frame pointer for all functions
A recent commit I made made it so that we only did this for signal or
interrupt handlers. This broke normal functions.
Modified:
llvm/trunk/lib/Target/AVR/AVRFrameLowering.cpp
llvm/trunk/test/CodeGen/AVR/calling-conv/c/stack.ll
llvm/trunk/test/CodeGen/AVR/return.ll
llvm/trunk/test/CodeGen/AVR/varargs.ll
Modified: llvm/trunk/lib/Target/AVR/AVRFrameLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AVR/AVRFrameLowering.cpp?rev=301893&r1=301892&r2=301893&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AVR/AVRFrameLowering.cpp (original)
+++ llvm/trunk/lib/Target/AVR/AVRFrameLowering.cpp Mon May 1 20:57:48 2017
@@ -66,18 +66,17 @@ void AVRFrameLowering::emitPrologue(Mach
.setMIFlag(MachineInstr::FrameSetup);
}
+ // Save the frame pointer if we have one.
+ if (HasFP) {
+ BuildMI(MBB, MBBI, DL, TII.get(AVR::PUSHWRr))
+ .addReg(AVR::R29R28, RegState::Kill)
+ .setMIFlag(MachineInstr::FrameSetup);
+ }
+
// Emit special prologue code to save R1, R0 and SREG in interrupt/signal
// handlers before saving any other registers.
if (CallConv == CallingConv::AVR_INTR ||
CallConv == CallingConv::AVR_SIGNAL) {
-
- // Save the frame pointer if we have one.
- if (HasFP) {
- BuildMI(MBB, MBBI, DL, TII.get(AVR::PUSHWRr))
- .addReg(AVR::R29R28, RegState::Kill)
- .setMIFlag(MachineInstr::FrameSetup);
- }
-
BuildMI(MBB, MBBI, DL, TII.get(AVR::PUSHWRr))
.addReg(AVR::R1R0, RegState::Kill)
.setMIFlag(MachineInstr::FrameSetup);
@@ -173,11 +172,11 @@ void AVRFrameLowering::emitEpilogue(Mach
.addImm(0x3f)
.addReg(AVR::R0, RegState::Kill);
BuildMI(MBB, MBBI, DL, TII.get(AVR::POPWRd), AVR::R1R0);
-
- if (hasFP(MF))
- BuildMI(MBB, MBBI, DL, TII.get(AVR::POPWRd), AVR::R29R28);
}
+ if (hasFP(MF))
+ BuildMI(MBB, MBBI, DL, TII.get(AVR::POPWRd), AVR::R29R28);
+
// Early exit if there is no need to restore the frame pointer.
if (!FrameSize) {
return;
Modified: llvm/trunk/test/CodeGen/AVR/calling-conv/c/stack.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AVR/calling-conv/c/stack.ll?rev=301893&r1=301892&r2=301893&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AVR/calling-conv/c/stack.ll (original)
+++ llvm/trunk/test/CodeGen/AVR/calling-conv/c/stack.ll Mon May 1 20:57:48 2017
@@ -11,15 +11,15 @@ define void @ret_void_args_i64_i64_i32(i
; CHECK-NEXT: in r29, 62
; Load the top two bytes from the 32-bit int.
- ; CHECK-NEXT: ldd r24, Y+7
- ; CHECK-NEXT: ldd r25, Y+8
+ ; CHECK-NEXT: ldd r24, Y+5
+ ; CHECK-NEXT: ldd r25, Y+6
; Store the top two bytes of the 32-bit int to memory.
; CHECK-NEXT: sts 7, r25
; CHECK-NEXT: sts 6, r24
; Load the bottom two bytes from the 32-bit int.
- ; CHECK-NEXT: ldd r24, Y+5
- ; CHECK-NEXT: ldd r25, Y+6
+ ; CHECK-NEXT: ldd r24, Y+3
+ ; CHECK-NEXT: ldd r25, Y+4
; Store the bottom two bytes of the 32-bit int to memory.
; CHECK-NEXT: sts 5, r25
; CHECK-NEXT: sts 4, r24
Modified: llvm/trunk/test/CodeGen/AVR/return.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AVR/return.ll?rev=301893&r1=301892&r2=301893&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AVR/return.ll (original)
+++ llvm/trunk/test/CodeGen/AVR/return.ll Mon May 1 20:57:48 2017
@@ -96,14 +96,14 @@ define i64 @return64_arg2(i64 %x, i64 %y
; CHECK-LABEL: return64_arg2:
; CHECK: push r28
; CHECK: push r29
-; CHECK: ldd r18, Y+5
-; CHECK: ldd r19, Y+6
-; CHECK: ldd r20, Y+7
-; CHECK: ldd r21, Y+8
-; CHECK: ldd r22, Y+9
-; CHECK: ldd r23, Y+10
-; CHECK: ldd r24, Y+11
-; CHECK: ldd r25, Y+12
+; CHECK: ldd r18, Y+3
+; CHECK: ldd r19, Y+4
+; CHECK: ldd r20, Y+5
+; CHECK: ldd r21, Y+6
+; CHECK: ldd r22, Y+7
+; CHECK: ldd r23, Y+8
+; CHECK: ldd r24, Y+9
+; CHECK: ldd r25, Y+10
; CHECK: pop r29
; CHECK: pop r28
ret i64 %z
@@ -113,10 +113,10 @@ define i32 @return64_trunc(i32 %a, i32 %
; CHECK-LABEL: return64_trunc:
; CHECK: push r28
; CHECK: push r29
-; CHECK: ldd r22, Y+5
-; CHECK: ldd r23, Y+6
-; CHECK: ldd r24, Y+7
-; CHECK: ldd r25, Y+8
+; CHECK: ldd r22, Y+3
+; CHECK: ldd r23, Y+4
+; CHECK: ldd r24, Y+5
+; CHECK: ldd r25, Y+6
; CHECK: pop r29
; CHECK: pop r28
%result = trunc i64 %d to i32
Modified: llvm/trunk/test/CodeGen/AVR/varargs.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AVR/varargs.ll?rev=301893&r1=301892&r2=301893&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AVR/varargs.ll (original)
+++ llvm/trunk/test/CodeGen/AVR/varargs.ll Mon May 1 20:57:48 2017
@@ -7,12 +7,12 @@ declare void @llvm.va_end(i8*)
define i16 @varargs1(i8* nocapture %x, ...) {
; CHECK-LABEL: varargs1:
; CHECK: movw r20, r28
-; CHECK: subi r20, 215
+; CHECK: subi r20, 217
; CHECK: sbci r21, 255
; CHECK: movw r24, r28
; CHECK: adiw r24, 3
-; CHECK: ldd r22, Y+39
-; CHECK: ldd r23, Y+40
+; CHECK: ldd r22, Y+37
+; CHECK: ldd r23, Y+38
; CHECK: call
%buffer = alloca [32 x i8]
%ap = alloca i8*
More information about the llvm-commits
mailing list