[llvm] c85175c - [AVR] Fix a bug in prologue of ISR
Ben Shi via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 29 06:44:58 PDT 2021
Author: Ben Shi
Date: 2021-06-29T21:44:50+08:00
New Revision: c85175c5f6a96e44b3b343fa7b26d66bbc0b4973
URL: https://github.com/llvm/llvm-project/commit/c85175c5f6a96e44b3b343fa7b26d66bbc0b4973
DIFF: https://github.com/llvm/llvm-project/commit/c85175c5f6a96e44b3b343fa7b26d66bbc0b4973.diff
LOG: [AVR] Fix a bug in prologue of ISR
The r1 register should be cleared in prologue of ISR as it is used
as constant zero.
Reviewed By: dylanmckay
Differential Revision: https://reviews.llvm.org/D99467
Added:
Modified:
llvm/lib/Target/AVR/AVRFrameLowering.cpp
llvm/test/CodeGen/AVR/interrupts.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/AVR/AVRFrameLowering.cpp b/llvm/lib/Target/AVR/AVRFrameLowering.cpp
index e99801032037..89ed30e8bcdb 100644
--- a/llvm/lib/Target/AVR/AVRFrameLowering.cpp
+++ b/llvm/lib/Target/AVR/AVRFrameLowering.cpp
@@ -83,6 +83,11 @@ void AVRFrameLowering::emitPrologue(MachineFunction &MF,
.addReg(AVR::R0, RegState::Kill)
.addReg(AVR::R0, RegState::Kill)
.setMIFlag(MachineInstr::FrameSetup);
+ BuildMI(MBB, MBBI, DL, TII.get(AVR::EORRdRr))
+ .addReg(AVR::R1, RegState::Define)
+ .addReg(AVR::R1, RegState::Kill)
+ .addReg(AVR::R1, RegState::Kill)
+ .setMIFlag(MachineInstr::FrameSetup);
}
// Early exit if the frame pointer is not needed in this function.
diff --git a/llvm/test/CodeGen/AVR/interrupts.ll b/llvm/test/CodeGen/AVR/interrupts.ll
index c6550a0fb6ae..e112de0a0ddd 100644
--- a/llvm/test/CodeGen/AVR/interrupts.ll
+++ b/llvm/test/CodeGen/AVR/interrupts.ll
@@ -8,6 +8,7 @@ define avr_intrcc void @interrupt_handler() {
; CHECK-NEXT: in r0, 63
; CHECK-NEXT: push r0
; CHECK: clr r0
+; CHECK-NEXT: clr r1
; CHECK: pop r0
; CHECK-NEXT: out 63, r0
; CHECK-NEXT: pop r1
@@ -24,6 +25,7 @@ define void @interrupt_handler_via_ir_attribute() #0 {
; CHECK-NEXT: in r0, 63
; CHECK-NEXT: push r0
; CHECK: clr r0
+; CHECK-NEXT: clr r1
; CHECK: pop r0
; CHECK-NEXT: out 63, r0
; CHECK-NEXT: pop r1
@@ -40,6 +42,7 @@ define avr_signalcc void @signal_handler() {
; CHECK-NEXT: in r0, 63
; CHECK-NEXT: push r0
; CHECK: clr r0
+; CHECK-NEXT: clr r1
; CHECK: pop r0
; CHECK-NEXT: out 63, r0
; CHECK-NEXT: pop r1
@@ -56,6 +59,7 @@ define void @signal_handler_via_attribute() #1 {
; CHECK-NEXT: in r0, 63
; CHECK-NEXT: push r0
; CHECK: clr r0
+; CHECK-NEXT: clr r1
; CHECK: pop r0
; CHECK-NEXT: out 63, r0
; CHECK-NEXT: pop r1
@@ -72,6 +76,7 @@ define avr_intrcc void @interrupt_alloca() {
; CHECK-NEXT: in r0, 63
; CHECK-NEXT: push r0
; CHECK: clr r0
+; CHECK-NEXT: clr r1
; CHECK: push r28
; CHECK-NEXT: push r29
; CHECK-NEXT: in r28, 61
More information about the llvm-commits
mailing list