[AVR] fix interrupt stack pointer restoration
authorAndrew Dona-Couch <hi@andrewcou.ch>
Thu, 1 Oct 2020 05:49:12 +0000 (18:49 +1300)
committerDylan McKay <me@dylanmckay.io>
Thu, 1 Oct 2020 05:52:13 +0000 (18:52 +1300)
commit1fedd90cc7a8deabf7d75d3e668bd56ce9b1ffcc
tree9f430cdd11f0ccd3f6edfac805a8ded377bf8b45
parent71dcbe1e88b446ae7f405da1b3006b966ccc6ca6
[AVR] fix interrupt stack pointer restoration

This patch fixes a corruption of the stack pointer and several registers in any AVR interrupt with non-empty stack frame.  Previously, the callee-saved registers were popped before restoring the stack pointer, causing the pointer math to use the wrong base value while also corrupting the caller's register.  This change fixes the code to restore the stack pointer last before exiting the interrupt service routine.

https://bugs.llvm.org/show_bug.cgi?id=47253

Reviewed By: dylanmckay

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

Patch by Andrew Dona-Couch.
llvm/lib/Target/AVR/AVRFrameLowering.cpp
llvm/test/CodeGen/AVR/interrupts.ll