xref: /llvm-project/llvm/test/MC/ELF/cfi-label.s (revision 2718654c542c742e2dd18dcda8b93de1d4d3b640)
1# RUN: llvm-mc -triple x86_64 %s | FileCheck %s --check-prefix=ASM
2# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t
3# RUN: llvm-readelf -sX %t | FileCheck %s --check-prefix=SYMTAB
4# RUN: llvm-dwarfdump --eh-frame %t | FileCheck %s
5
6# RUN: not llvm-mc -filetype=obj -triple=x86_64 --defsym ERR=1 %s -o /dev/null 2>&1 | \
7# RUN:   FileCheck %s --check-prefix=ERR --implicit-check-not=error:
8
9# ASM:      nop
10# ASM-NEXT: .cfi_label cfi1
11# ASM-NEXT: .cfi_escape 0x00
12# ASM:      .globl cfi2
13# ASM-NEXT: .cfi_label cfi2
14# ASM:      nop
15# ASM-NEXT: .cfi_label .Lcfi3
16
17# SYMTAB:      000000000000002b     0 NOTYPE  LOCAL  DEFAULT     3 (.eh_frame) cfi1
18# SYMTAB:      000000000000002d     0 NOTYPE  GLOBAL DEFAULT     3 (.eh_frame) cfi2
19# SYMTAB-NOT:  {{.}}
20
21# CHECK:       DW_CFA_remember_state:
22# CHECK-NEXT:  DW_CFA_advance_loc: 1 to 0x1
23# CHECK-NEXT:  DW_CFA_nop:
24# CHECK-NEXT:  DW_CFA_advance_loc: 1 to 0x2
25# CHECK-NEXT:  DW_CFA_nop:
26# CHECK-NEXT:  DW_CFA_nop:
27# CHECK-NEXT:  DW_CFA_advance_loc: 1 to 0x3
28# CHECK-NEXT:  DW_CFA_nop:
29# CHECK-NEXT:  DW_CFA_nop:
30# CHECK-NEXT:  DW_CFA_nop:
31# CHECK-NEXT:  DW_CFA_restore_state:
32
33.globl foo
34foo:
35.cfi_startproc
36.cfi_remember_state
37nop
38.cfi_label cfi1
39.cfi_escape 0
40nop
41.globl cfi2
42.cfi_label cfi2
43.cfi_escape 0, 0
44nop
45.cfi_label .Lcfi3
46.cfi_escape 0, 0, 0
47.cfi_restore_state
48ret
49
50# ERR: [[#@LINE+10]]:1: error: this directive must appear between .cfi_startproc and .cfi_endproc directives
51.ifdef ERR
52# ERR: [[#@LINE+1]]:12: error: symbol 'foo' is already defined
53.cfi_label foo
54# ERR: [[#@LINE+1]]:12: error: symbol '.Lcfi3' is already defined
55.cfi_label .Lcfi3
56.endif
57.cfi_endproc
58
59.ifdef ERR
60.cfi_label after_endproc
61.endif
62