File: compact-unwind-cfi_def_cfa.s

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-16
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,496,368 kB
  • sloc: cpp: 5,593,980; ansic: 986,873; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,547; xml: 953; cs: 573; fortran: 567
file content (89 lines) | stat: -rw-r--r-- 2,018 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// RUN: llvm-mc -triple x86_64-apple-darwin -filetype=obj %s -o - | llvm-readobj --sections - | FileCheck %s

// We were trying to generate compact unwind info for assembly like this.
// The .cfi_def_cfa directive, however, throws a wrench into that and was
// causing an llvm_unreachable() failure. Make sure the assembler can handle
// the input. The actual eh_frames created using these directives are checked
// elsewhere. This test is a simpler "does the code assemble" check.

// rdar://15406518

.macro SaveRegisters

 push %rbp
 .cfi_def_cfa_offset 16
 .cfi_offset rbp, -16

 mov %rsp, %rbp
 .cfi_def_cfa_register rbp

 sub $$0x80+8, %rsp

 movdqa %xmm0, -0x80(%rbp)
 push %rax
 movdqa %xmm1, -0x70(%rbp)
 push %rdi
 movdqa %xmm2, -0x60(%rbp)
 push %rsi
 movdqa %xmm3, -0x50(%rbp)
 push %rdx
 movdqa %xmm4, -0x40(%rbp)
 push %rcx
 movdqa %xmm5, -0x30(%rbp)
 push %r8
 movdqa %xmm6, -0x20(%rbp)
 push %r9
 movdqa %xmm7, -0x10(%rbp)

.endmacro
.macro RestoreRegisters

 movdqa -0x80(%rbp), %xmm0
 pop %r9
 movdqa -0x70(%rbp), %xmm1
 pop %r8
 movdqa -0x60(%rbp), %xmm2
 pop %rcx
 movdqa -0x50(%rbp), %xmm3
 pop %rdx
 movdqa -0x40(%rbp), %xmm4
 pop %rsi
 movdqa -0x30(%rbp), %xmm5
 pop %rdi
 movdqa -0x20(%rbp), %xmm6
 pop %rax
 movdqa -0x10(%rbp), %xmm7

 leave
 .cfi_def_cfa rsp, 8
 .cfi_same_value rbp

.endmacro

_foo:
.cfi_startproc
  SaveRegisters

  RestoreRegisters
  ret
 .cfi_endproc

// CHECK: Section {
// CHECK:   Index: 1
// CHECK:   Name: __eh_frame (5F 5F 65 68 5F 66 72 61 6D 65 00 00 00 00 00 00)
// CHECK:   Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
// CHECK:   Address: 0x70
// CHECK:   Size: 0x40
// CHECK:   Offset: 480
// CHECK:   Alignment: 3
// CHECK:   RelocationOffset: 0x0
// CHECK:   RelocationCount: 0
// CHECK:   Type: Coalesced (0xB)
// CHECK:   Attributes [ (0x680000)
// CHECK:     LiveSupport (0x80000)
// CHECK:     NoTOC (0x400000)
// CHECK:     StripStaticSyms (0x200000)
// CHECK:   ]
// CHECK:   Reserved1: 0x0
// CHECK:   Reserved2: 0x0
// CHECK: }