llvm/llvm/test/CodeGen/PowerPC/aix-spills-for-eh.ll

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mcpu=pwr9 -mattr=+altivec -verify-machineinstrs --vec-extabi \
; RUN:   -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr \
; RUN:   -mtriple=powerpc-unknown-aix < %s  | FileCheck %s --check-prefix 32BIT

; RUN: llc -mcpu=pwr9 -mattr=+altivec -verify-machineinstrs --vec-extabi \
; RUN:   -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr \
; RUN:   -mtriple=powerpc64-unknown-aix < %s | FileCheck %s --check-prefix 64BIT

@_ZTIi = external constant ptr

; Function Attrs: uwtable mustprogress
define dso_local signext i32 @_Z5test2iPPKc(i32 signext %argc, ptr nocapture readnone %argv) local_unnamed_addr #0 personality ptr @__gxx_personality_v0{
; 32BIT-LABEL: _Z5test2iPPKc:
; 32BIT:       # %bb.0: # %entry
; 32BIT-NEXT:    mflr r0
; 32BIT-NEXT:    stwu r1, -464(r1)
; 32BIT-NEXT:    stw r0, 472(r1)
; 32BIT-NEXT:    stw r30, 320(r1) # 4-byte Folded Spill
; 32BIT-NEXT:    li r30, 0
; 32BIT-NEXT:    stxv v20, 64(r1) # 16-byte Folded Spill
; 32BIT-NEXT:    stxv v21, 80(r1) # 16-byte Folded Spill
; 32BIT-NEXT:    stw r31, 324(r1) # 4-byte Folded Spill
; 32BIT-NEXT:    mr r31, r3
; 32BIT-NEXT:    stw r14, 256(r1) # 4-byte Folded Spill
; 32BIT-NEXT:    stxv v22, 96(r1) # 16-byte Folded Spill
; 32BIT-NEXT:    stw r15, 260(r1) # 4-byte Folded Spill
; 32BIT-NEXT:    stxv v23, 112(r1) # 16-byte Folded Spill
; 32BIT-NEXT:    stw r16, 264(r1) # 4-byte Folded Spill
; 32BIT-NEXT:    stxv v24, 128(r1) # 16-byte Folded Spill
; 32BIT-NEXT:    stw r17, 268(r1) # 4-byte Folded Spill
; 32BIT-NEXT:    stw r18, 272(r1) # 4-byte Folded Spill
; 32BIT-NEXT:    stxv v25, 144(r1) # 16-byte Folded Spill
; 32BIT-NEXT:    stw r19, 276(r1) # 4-byte Folded Spill
; 32BIT-NEXT:    stxv v26, 160(r1) # 16-byte Folded Spill
; 32BIT-NEXT:    stw r20, 280(r1) # 4-byte Folded Spill
; 32BIT-NEXT:    stxv v27, 176(r1) # 16-byte Folded Spill
; 32BIT-NEXT:    stw r21, 284(r1) # 4-byte Folded Spill
; 32BIT-NEXT:    stw r22, 288(r1) # 4-byte Folded Spill
; 32BIT-NEXT:    stxv v28, 192(r1) # 16-byte Folded Spill
; 32BIT-NEXT:    stw r23, 292(r1) # 4-byte Folded Spill
; 32BIT-NEXT:    stxv v29, 208(r1) # 16-byte Folded Spill
; 32BIT-NEXT:    stw r24, 296(r1) # 4-byte Folded Spill
; 32BIT-NEXT:    stxv v30, 224(r1) # 16-byte Folded Spill
; 32BIT-NEXT:    stw r25, 300(r1) # 4-byte Folded Spill
; 32BIT-NEXT:    stw r26, 304(r1) # 4-byte Folded Spill
; 32BIT-NEXT:    stxv v31, 240(r1) # 16-byte Folded Spill
; 32BIT-NEXT:    stw r27, 308(r1) # 4-byte Folded Spill
; 32BIT-NEXT:    stw r28, 312(r1) # 4-byte Folded Spill
; 32BIT-NEXT:    stw r29, 316(r1) # 4-byte Folded Spill
; 32BIT-NEXT:    stfd f15, 328(r1) # 8-byte Folded Spill
; 32BIT-NEXT:    stfd f16, 336(r1) # 8-byte Folded Spill
; 32BIT-NEXT:    stfd f17, 344(r1) # 8-byte Folded Spill
; 32BIT-NEXT:    stfd f18, 352(r1) # 8-byte Folded Spill
; 32BIT-NEXT:    stfd f19, 360(r1) # 8-byte Folded Spill
; 32BIT-NEXT:    stfd f20, 368(r1) # 8-byte Folded Spill
; 32BIT-NEXT:    stfd f21, 376(r1) # 8-byte Folded Spill
; 32BIT-NEXT:    stfd f22, 384(r1) # 8-byte Folded Spill
; 32BIT-NEXT:    stfd f23, 392(r1) # 8-byte Folded Spill
; 32BIT-NEXT:    stfd f24, 400(r1) # 8-byte Folded Spill
; 32BIT-NEXT:    stfd f25, 408(r1) # 8-byte Folded Spill
; 32BIT-NEXT:    stfd f26, 416(r1) # 8-byte Folded Spill
; 32BIT-NEXT:    stfd f27, 424(r1) # 8-byte Folded Spill
; 32BIT-NEXT:    stfd f28, 432(r1) # 8-byte Folded Spill
; 32BIT-NEXT:    stfd f29, 440(r1) # 8-byte Folded Spill
; 32BIT-NEXT:    stfd f30, 448(r1) # 8-byte Folded Spill
; 32BIT-NEXT:    stfd f31, 456(r1) # 8-byte Folded Spill
; 32BIT-NEXT:    #APP
; 32BIT-NEXT:    nop
; 32BIT-NEXT:    #NO_APP
; 32BIT-NEXT:  L..tmp0:
; 32BIT-NEXT:    bl ._Z4testi[PR]
; 32BIT-NEXT:    nop
; 32BIT-NEXT:  L..tmp1:
; 32BIT-NEXT:  L..BB0_1: # %return
; 32BIT-NEXT:    lxv v31, 240(r1) # 16-byte Folded Reload
; 32BIT-NEXT:    lxv v30, 224(r1) # 16-byte Folded Reload
; 32BIT-NEXT:    lxv v29, 208(r1) # 16-byte Folded Reload
; 32BIT-NEXT:    lxv v28, 192(r1) # 16-byte Folded Reload
; 32BIT-NEXT:    mr r3, r30
; 32BIT-NEXT:    lxv v27, 176(r1) # 16-byte Folded Reload
; 32BIT-NEXT:    lxv v26, 160(r1) # 16-byte Folded Reload
; 32BIT-NEXT:    lxv v25, 144(r1) # 16-byte Folded Reload
; 32BIT-NEXT:    lxv v24, 128(r1) # 16-byte Folded Reload
; 32BIT-NEXT:    lxv v23, 112(r1) # 16-byte Folded Reload
; 32BIT-NEXT:    lxv v22, 96(r1) # 16-byte Folded Reload
; 32BIT-NEXT:    lxv v21, 80(r1) # 16-byte Folded Reload
; 32BIT-NEXT:    lxv v20, 64(r1) # 16-byte Folded Reload
; 32BIT-NEXT:    lfd f31, 456(r1) # 8-byte Folded Reload
; 32BIT-NEXT:    lfd f30, 448(r1) # 8-byte Folded Reload
; 32BIT-NEXT:    lfd f29, 440(r1) # 8-byte Folded Reload
; 32BIT-NEXT:    lfd f28, 432(r1) # 8-byte Folded Reload
; 32BIT-NEXT:    lwz r31, 324(r1) # 4-byte Folded Reload
; 32BIT-NEXT:    lwz r30, 320(r1) # 4-byte Folded Reload
; 32BIT-NEXT:    lwz r29, 316(r1) # 4-byte Folded Reload
; 32BIT-NEXT:    lfd f27, 424(r1) # 8-byte Folded Reload
; 32BIT-NEXT:    lwz r28, 312(r1) # 4-byte Folded Reload
; 32BIT-NEXT:    lwz r27, 308(r1) # 4-byte Folded Reload
; 32BIT-NEXT:    lwz r26, 304(r1) # 4-byte Folded Reload
; 32BIT-NEXT:    lfd f26, 416(r1) # 8-byte Folded Reload
; 32BIT-NEXT:    lwz r25, 300(r1) # 4-byte Folded Reload
; 32BIT-NEXT:    lwz r24, 296(r1) # 4-byte Folded Reload
; 32BIT-NEXT:    lwz r23, 292(r1) # 4-byte Folded Reload
; 32BIT-NEXT:    lfd f25, 408(r1) # 8-byte Folded Reload
; 32BIT-NEXT:    lwz r22, 288(r1) # 4-byte Folded Reload
; 32BIT-NEXT:    lwz r21, 284(r1) # 4-byte Folded Reload
; 32BIT-NEXT:    lwz r20, 280(r1) # 4-byte Folded Reload
; 32BIT-NEXT:    lfd f24, 400(r1) # 8-byte Folded Reload
; 32BIT-NEXT:    lwz r19, 276(r1) # 4-byte Folded Reload
; 32BIT-NEXT:    lwz r18, 272(r1) # 4-byte Folded Reload
; 32BIT-NEXT:    lwz r17, 268(r1) # 4-byte Folded Reload
; 32BIT-NEXT:    lfd f23, 392(r1) # 8-byte Folded Reload
; 32BIT-NEXT:    lwz r16, 264(r1) # 4-byte Folded Reload
; 32BIT-NEXT:    lwz r15, 260(r1) # 4-byte Folded Reload
; 32BIT-NEXT:    lwz r14, 256(r1) # 4-byte Folded Reload
; 32BIT-NEXT:    lfd f22, 384(r1) # 8-byte Folded Reload
; 32BIT-NEXT:    lfd f21, 376(r1) # 8-byte Folded Reload
; 32BIT-NEXT:    lfd f20, 368(r1) # 8-byte Folded Reload
; 32BIT-NEXT:    lfd f19, 360(r1) # 8-byte Folded Reload
; 32BIT-NEXT:    lfd f18, 352(r1) # 8-byte Folded Reload
; 32BIT-NEXT:    lfd f17, 344(r1) # 8-byte Folded Reload
; 32BIT-NEXT:    lfd f16, 336(r1) # 8-byte Folded Reload
; 32BIT-NEXT:    lfd f15, 328(r1) # 8-byte Folded Reload
; 32BIT-NEXT:    addi r1, r1, 464
; 32BIT-NEXT:    lwz r0, 8(r1)
; 32BIT-NEXT:    mtlr r0
; 32BIT-NEXT:    blr
; 32BIT-NEXT:  L..BB0_2: # %lpad
; 32BIT-NEXT:  L..tmp2:
; 32BIT-NEXT:    bl .__cxa_begin_catch[PR]
; 32BIT-NEXT:    nop
; 32BIT-NEXT:    lwz r3, 0(r3)
; 32BIT-NEXT:    add r30, r3, r31
; 32BIT-NEXT:    bl .__cxa_end_catch[PR]
; 32BIT-NEXT:    nop
; 32BIT-NEXT:    b L..BB0_1
;
; 64BIT-LABEL: _Z5test2iPPKc:
; 64BIT:       # %bb.0: # %entry
; 64BIT-NEXT:    mflr r0
; 64BIT-NEXT:    stdu r1, -592(r1)
; 64BIT-NEXT:    std r0, 608(r1)
; 64BIT-NEXT:    std r30, 440(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    li r30, 0
; 64BIT-NEXT:    stxv v20, 112(r1) # 16-byte Folded Spill
; 64BIT-NEXT:    stxv v21, 128(r1) # 16-byte Folded Spill
; 64BIT-NEXT:    std r31, 448(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    mr r31, r3
; 64BIT-NEXT:    std r14, 312(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stxv v22, 144(r1) # 16-byte Folded Spill
; 64BIT-NEXT:    std r15, 320(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stxv v23, 160(r1) # 16-byte Folded Spill
; 64BIT-NEXT:    std r16, 328(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stxv v24, 176(r1) # 16-byte Folded Spill
; 64BIT-NEXT:    std r17, 336(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    std r18, 344(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stxv v25, 192(r1) # 16-byte Folded Spill
; 64BIT-NEXT:    std r19, 352(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stxv v26, 208(r1) # 16-byte Folded Spill
; 64BIT-NEXT:    std r20, 360(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stxv v27, 224(r1) # 16-byte Folded Spill
; 64BIT-NEXT:    std r21, 368(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    std r22, 376(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stxv v28, 240(r1) # 16-byte Folded Spill
; 64BIT-NEXT:    std r23, 384(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stxv v29, 256(r1) # 16-byte Folded Spill
; 64BIT-NEXT:    std r24, 392(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stxv v30, 272(r1) # 16-byte Folded Spill
; 64BIT-NEXT:    std r25, 400(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    std r26, 408(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stxv v31, 288(r1) # 16-byte Folded Spill
; 64BIT-NEXT:    std r27, 416(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    std r28, 424(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    std r29, 432(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stfd f15, 456(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stfd f16, 464(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stfd f17, 472(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stfd f18, 480(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stfd f19, 488(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stfd f20, 496(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stfd f21, 504(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stfd f22, 512(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stfd f23, 520(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stfd f24, 528(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stfd f25, 536(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stfd f26, 544(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stfd f27, 552(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stfd f28, 560(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stfd f29, 568(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stfd f30, 576(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    stfd f31, 584(r1) # 8-byte Folded Spill
; 64BIT-NEXT:    #APP
; 64BIT-NEXT:    nop
; 64BIT-NEXT:    #NO_APP
; 64BIT-NEXT:  L..tmp0:
; 64BIT-NEXT:    bl ._Z4testi[PR]
; 64BIT-NEXT:    nop
; 64BIT-NEXT:  L..tmp1:
; 64BIT-NEXT:  L..BB0_1: # %return
; 64BIT-NEXT:    lxv v31, 288(r1) # 16-byte Folded Reload
; 64BIT-NEXT:    lxv v30, 272(r1) # 16-byte Folded Reload
; 64BIT-NEXT:    lxv v29, 256(r1) # 16-byte Folded Reload
; 64BIT-NEXT:    lxv v28, 240(r1) # 16-byte Folded Reload
; 64BIT-NEXT:    extsw r3, r30
; 64BIT-NEXT:    lxv v27, 224(r1) # 16-byte Folded Reload
; 64BIT-NEXT:    lxv v26, 208(r1) # 16-byte Folded Reload
; 64BIT-NEXT:    lxv v25, 192(r1) # 16-byte Folded Reload
; 64BIT-NEXT:    lxv v24, 176(r1) # 16-byte Folded Reload
; 64BIT-NEXT:    lxv v23, 160(r1) # 16-byte Folded Reload
; 64BIT-NEXT:    lxv v22, 144(r1) # 16-byte Folded Reload
; 64BIT-NEXT:    lxv v21, 128(r1) # 16-byte Folded Reload
; 64BIT-NEXT:    lxv v20, 112(r1) # 16-byte Folded Reload
; 64BIT-NEXT:    lfd f31, 584(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    lfd f30, 576(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    lfd f29, 568(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    lfd f28, 560(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    ld r31, 448(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    ld r30, 440(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    ld r29, 432(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    lfd f27, 552(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    ld r28, 424(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    ld r27, 416(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    ld r26, 408(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    lfd f26, 544(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    ld r25, 400(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    ld r24, 392(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    ld r23, 384(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    lfd f25, 536(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    ld r22, 376(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    ld r21, 368(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    ld r20, 360(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    lfd f24, 528(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    ld r19, 352(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    ld r18, 344(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    ld r17, 336(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    lfd f23, 520(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    ld r16, 328(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    ld r15, 320(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    ld r14, 312(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    lfd f22, 512(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    lfd f21, 504(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    lfd f20, 496(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    lfd f19, 488(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    lfd f18, 480(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    lfd f17, 472(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    lfd f16, 464(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    lfd f15, 456(r1) # 8-byte Folded Reload
; 64BIT-NEXT:    addi r1, r1, 592
; 64BIT-NEXT:    ld r0, 16(r1)
; 64BIT-NEXT:    mtlr r0
; 64BIT-NEXT:    blr
; 64BIT-NEXT:  L..BB0_2: # %lpad
; 64BIT-NEXT:  L..tmp2:
; 64BIT-NEXT:    bl .__cxa_begin_catch[PR]
; 64BIT-NEXT:    nop
; 64BIT-NEXT:    lwz r3, 0(r3)
; 64BIT-NEXT:    add r30, r3, r31
; 64BIT-NEXT:    bl .__cxa_end_catch[PR]
; 64BIT-NEXT:    nop
; 64BIT-NEXT:    b L..BB0_1
entry:
  tail call void asm sideeffect "nop", "~{r14},~{f15},~{v20}"()
  %call = invoke signext i32 @_Z4testi(i32 signext %argc)
          to label %return unwind label %lpad

lpad:                                             ; preds = %entry
  %0 = landingpad { ptr, i32 }
          catch ptr @_ZTIi
  %1 = extractvalue { ptr, i32 } %0, 1
  %2 = tail call i32 @llvm.eh.typeid.for(ptr @_ZTIi) #3
  %matches = icmp eq i32 %1, %2
  br i1 %matches, label %catch, label %eh.resume

catch:                                            ; preds = %lpad
  %3 = extractvalue { ptr, i32 } %0, 0
  %4 = tail call ptr @__cxa_begin_catch(ptr %3) #3
  %5 = load i32, ptr %4, align 4
  %add = add nsw i32 %5, %argc
  tail call void @__cxa_end_catch()
  br label %return

return:                                           ; preds = %entry, %catch
  %retval.0 = phi i32 [ %add, %catch ], [ 0, %entry ]
  ret i32 %retval.0

eh.resume:                                        ; preds = %lpad
  resume { ptr, i32 } %0
}

declare signext i32 @_Z4testi(i32 signext) local_unnamed_addr

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind readnone
declare i32 @llvm.eh.typeid.for(ptr)

declare ptr @__cxa_begin_catch(ptr) local_unnamed_addr

declare void @__cxa_end_catch() local_unnamed_addr

attributes #0 = { uwtable }