[AVR] Mark call-clobbered registers as clobbered in interrupt handlers
authorAyke van Laethem <aykevanlaethem@gmail.com>
Mon, 3 Jan 2022 19:29:27 +0000 (20:29 +0100)
committerAyke van Laethem <aykevanlaethem@gmail.com>
Wed, 19 Jan 2022 13:22:13 +0000 (14:22 +0100)
commit3d59d94a206a840d780c8f34610977734095149a
tree39a19a76258c123e3e4552c9c6c6065c383cddd1
parentf41d2d9469d66b92c033616c080e196bdb07363a
[AVR] Mark call-clobbered registers as clobbered in interrupt handlers

I have matched the RISCV backend, which only uses the interrupt save
list in getCalleeSavedRegs, _not_ in getCallPreservedMask. I don't know
the details of these two methods, but with it, the correct amount of
registers is saved and restored.

Without this patch, practically all interrupt handlers that call a
function will miscompile.

I have added a test to verify this behavior. I've also added a very
simple test to verify that more normal interrupt operations (in this
case, incrementing a global value) behave as expected.

Differential Revision: https://reviews.llvm.org/D116551
llvm/lib/Target/AVR/AVRCallingConv.td
llvm/lib/Target/AVR/AVRRegisterInfo.cpp
llvm/test/CodeGen/AVR/interrupts.ll