xref: /llvm-project/llvm/test/CodeGen/RISCV/eh-dwarf-cfa.ll (revision 97982a8c605fac7c86d02e641a6cd7898b3ca343)
1862f30a4SShao-Ce SUN; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2862f30a4SShao-Ce SUN; RUN: llc -mtriple=riscv32 < %s | FileCheck -check-prefix=RV32 %s
3862f30a4SShao-Ce SUN; RUN: llc -mtriple=riscv64 < %s | FileCheck -check-prefix=RV64 %s
4862f30a4SShao-Ce SUN
5862f30a4SShao-Ce SUNdefine void @dwarf() {
6862f30a4SShao-Ce SUN; RV32-LABEL: dwarf:
7862f30a4SShao-Ce SUN; RV32:       # %bb.0: # %entry
8862f30a4SShao-Ce SUN; RV32-NEXT:    addi sp, sp, -16
9862f30a4SShao-Ce SUN; RV32-NEXT:    .cfi_def_cfa_offset 16
10862f30a4SShao-Ce SUN; RV32-NEXT:    sw ra, 12(sp) # 4-byte Folded Spill
11862f30a4SShao-Ce SUN; RV32-NEXT:    .cfi_offset ra, -4
12862f30a4SShao-Ce SUN; RV32-NEXT:    addi a0, sp, 16
13eabaee0cSFangrui Song; RV32-NEXT:    call foo
14862f30a4SShao-Ce SUN; RV32-NEXT:    lw ra, 12(sp) # 4-byte Folded Reload
15*97982a8cSdlav-sc; RV32-NEXT:    .cfi_restore ra
16862f30a4SShao-Ce SUN; RV32-NEXT:    addi sp, sp, 16
17*97982a8cSdlav-sc; RV32-NEXT:    .cfi_def_cfa_offset 0
18862f30a4SShao-Ce SUN; RV32-NEXT:    ret
19862f30a4SShao-Ce SUN;
20862f30a4SShao-Ce SUN; RV64-LABEL: dwarf:
21862f30a4SShao-Ce SUN; RV64:       # %bb.0: # %entry
22862f30a4SShao-Ce SUN; RV64-NEXT:    addi sp, sp, -16
23862f30a4SShao-Ce SUN; RV64-NEXT:    .cfi_def_cfa_offset 16
24862f30a4SShao-Ce SUN; RV64-NEXT:    sd ra, 8(sp) # 8-byte Folded Spill
25862f30a4SShao-Ce SUN; RV64-NEXT:    .cfi_offset ra, -8
26862f30a4SShao-Ce SUN; RV64-NEXT:    addi a0, sp, 16
27eabaee0cSFangrui Song; RV64-NEXT:    call foo
28862f30a4SShao-Ce SUN; RV64-NEXT:    ld ra, 8(sp) # 8-byte Folded Reload
29*97982a8cSdlav-sc; RV64-NEXT:    .cfi_restore ra
30862f30a4SShao-Ce SUN; RV64-NEXT:    addi sp, sp, 16
31*97982a8cSdlav-sc; RV64-NEXT:    .cfi_def_cfa_offset 0
32862f30a4SShao-Ce SUN; RV64-NEXT:    ret
33862f30a4SShao-Ce SUNentry:
341456b686SNikita Popov  %0 = call ptr @llvm.eh.dwarf.cfa(i32 0)
351456b686SNikita Popov  call void @foo(ptr %0)
36862f30a4SShao-Ce SUN  ret void
37862f30a4SShao-Ce SUN}
38862f30a4SShao-Ce SUN
391456b686SNikita Popovdeclare void @foo(ptr)
40862f30a4SShao-Ce SUN
411456b686SNikita Popovdeclare ptr @llvm.eh.dwarf.cfa(i32) nounwind
42