Investigation showed that in the AVR back end, under certain conditions of memory pressure, a corruption can occur with things like passing parameters on the stack.
The circumstances seem to need the PEI pass for AVR to attempt to rewrite the ADJCALLSTACKDOWN and STDWSPQRr/STDSPQRr instructions before the call to use the Z register as a temporary base pointer.
(See discussion at [https://discourse.llvm.org/t/avr-register-allocation-issue-help-advice-with-debugging/88498].)