This implements the missing stacksave/stackrestore intrinsics via expansion.
Output of llc -O0 -march=avr ~/devel/llvm/test/CodeGen/Generic/stacksave-restore.ll for sanity checking (comments mine):
.text .file ".../llvm/test/CodeGen/Generic/stacksave-restore.ll" .globl test .p2align 1 .type test,@function test: ; @test ; BB#0: # Save r28, r29 push r28 push r29 # SP -= 4, Y = SP in r28, 61 in r29, 62 sbiw r28, 4 in r0, 63 cli out 62, r29 out 63, r0 out 61, r28 # Save SP in r18, 61 in r19, 62 mov r20, r22 mov r21, r23 # stacksave (Z = SP) in r30, 61 in r31, 62 # alloca lsl r22 rol r23 lsl r22 rol r23 in r26, 61 in r27, 62 sub r26, r22 sbc r27, r23 andi r26, 252 in r0, 63 cli out 62, r27 out 63, r0 out 61, r26 # stackrestore (SP = Z) in r0, 63 cli out 62, r31 out 63, r0 out 61, r30 # alloca in r30, 61 in r31, 62 sub r30, r22 sbc r31, r23 andi r30, 252 in r0, 63 cli out 62, r31 out 63, r0 out 61, r30 std Y+3, r24 ; 2-byte Folded Spill std Y+4, r25 ; 2-byte Folded Spill # Set return value mov r24, r26 mov r25, r27 # Restore SP in r0, 63 cli out 62, r19 out 63, r0 out 61, r18 std Y+1, r20 ; 2-byte Folded Spill std Y+2, r21 ; 2-byte Folded Spill # SP = Y + 4 adiw r28, 4 in r0, 63 cli out 62, r29 out 63, r0 out 61, r28 # Restore r28, r29 pop r29 pop r28 ret .Lfunc_end0: .size test, .Lfunc_end0-test