1# RUN: llvm-mc -triple=i686-windows-msvc -filetype=obj < %s | llvm-readobj --codeview - | FileCheck %s
2
3# Test for .cv_fpo_stackalign. We should generate FPO data that restores CSRs
4# at each instruction, and in the last FrameData we should use the '@'
5# alignment operator to define $T0, the vframe value.
6
7# Based on this C code:
8# void usevals(int, int, double*);
9# int realign_with_csrs() {
10#   int a = getval();
11#   int b = getval();
12#   double __declspec(align(8)) force_alignment = 0.42;
13#   usevals(a, b, &force_alignment);
14#   return a + b;
15# }
16
17# CHECK: Subsection [
18# CHECK:   SubSectionType: Symbols (0xF1)
19# CHECK:   Compile3Sym {
20# CHECK:     Kind: S_COMPILE3 (0x113C)
21# CHECK:   }
22# CHECK: ]
23# CHECK: Subsection [
24# CHECK:   SubSectionType: FrameData (0xF5)
25# CHECK:   FrameData {
26# CHECK:     FrameFunc [
27# CHECK:       $T0 .raSearch =
28# CHECK:       $eip $T0 ^ =
29# CHECK:       $esp $T0 4 + =
30# CHECK:     ]
31# CHECK:   }
32# CHECK:   FrameData {
33# CHECK:     FrameFunc [
34# CHECK:       $T0 .raSearch =
35# CHECK:       $eip $T0 ^ =
36# CHECK:       $esp $T0 4 + =
37# CHECK:       $ebp $T0 4 - ^ =
38# CHECK:     ]
39# CHECK:   }
40# CHECK:   FrameData {
41# CHECK:     FrameFunc [
42# CHECK:       $T0 $ebp 4 + =
43# CHECK:       $eip $T0 ^ =
44# CHECK:       $esp $T0 4 + =
45# CHECK:       $ebp $T0 4 - ^ =
46# CHECK:     ]
47# CHECK:   }
48# CHECK:   FrameData {
49# CHECK:     FrameFunc [
50# CHECK:       $T0 $ebp 4 + =
51# CHECK:       $eip $T0 ^ =
52# CHECK:       $esp $T0 4 + =
53# CHECK:       $ebp $T0 4 - ^ =
54# CHECK:       $edi $T0 8 - ^ =
55# CHECK:     ]
56# CHECK:   }
57# CHECK:   FrameData {
58# CHECK:     FrameFunc [
59# CHECK:       $T0 $ebp 4 + =
60# CHECK:       $eip $T0 ^ =
61# CHECK:       $esp $T0 4 + =
62# CHECK:       $ebp $T0 4 - ^ =
63# CHECK:       $edi $T0 8 - ^ =
64# CHECK:       $esi $T0 12 - ^ =
65# CHECK:     ]
66# CHECK:   }
67# CHECK:   FrameData {
68# CHECK:     FrameFunc [
69# CHECK:       $T1 $ebp 4 + =
70# CHECK:       $T0 $T1 12 - 8 @ =
71# CHECK:       $eip $T1 ^ =
72# CHECK:       $esp $T1 4 + =
73# CHECK:       $ebp $T1 4 - ^ =
74# CHECK:       $edi $T1 8 - ^ =
75# CHECK:       $esi $T1 12 - ^ =
76# CHECK:     ]
77# CHECK:   }
78# CHECK: ]
79# CHECK: Subsection [
80# CHECK:   SubSectionType: Symbols (0xF1)
81# CHECK: ]
82# CHECK: Subsection [
83# CHECK:   SubSectionType: FileChecksums (0xF4)
84# CHECK: ]
85# CHECK: Subsection [
86# CHECK:   SubSectionType: StringTable (0xF3)
87# CHECK: ]
88
89	.text
90	.def	 _realign_with_csrs; .scl	2; .type	32; .endef
91	.globl	_realign_with_csrs      # -- Begin function realign_with_csrs
92_realign_with_csrs:                     # @realign_with_csrs
93Lfunc_begin0:
94	.cv_func_id 0
95	.cv_file	1 "C:\\src\\llvm-project\\build\\t.c" "2A4F9B6BBBF7845521201755D1B14ACC" 1
96	.cv_loc	0 1 4 0                 # t.c:4:0
97	.cv_fpo_proc	_realign_with_csrs 0
98# %bb.0:                                # %entry
99	pushl	%ebp
100	.cv_fpo_pushreg	%ebp
101	movl	%esp, %ebp
102	.cv_fpo_setframe	%ebp
103Ltmp0:
104	pushl	%edi
105	.cv_fpo_pushreg	%edi
106	pushl	%esi
107	.cv_fpo_pushreg	%esi
108	andl	$-8, %esp
109	.cv_fpo_stackalign	8
110	subl	$8, %esp
111	.cv_fpo_stackalloc	8
112	.cv_fpo_endprologue
113	.cv_loc	0 1 5 0                 # t.c:5:0
114	calll	_getval
115	movl	%eax, %esi
116	.cv_loc	0 1 6 0                 # t.c:6:0
117	calll	_getval
118	movl	%eax, %edi
119	movl	%esp, %eax
120	.cv_loc	0 1 7 0                 # t.c:7:0
121	movl	$1071309127, 4(%esp)    # imm = 0x3FDAE147
122	movl	$-1374389535, (%esp)    # imm = 0xAE147AE1
123	.cv_loc	0 1 8 0                 # t.c:8:0
124	pushl	%eax
125	pushl	%edi
126	pushl	%esi
127	calll	_usevals
128	addl	$12, %esp
129	.cv_loc	0 1 9 0                 # t.c:9:0
130	addl	%esi, %edi
131	movl	%edi, %eax
132	leal	-8(%ebp), %esp
133	popl	%esi
134	popl	%edi
135	popl	%ebp
136	retl
137Ltmp1:
138	.cv_fpo_endproc
139Lfunc_end0:
140                                        # -- End function
141	.section	.debug$S,"dr"
142	.p2align	2
143	.long	4                       # Debug section magic
144	.long	241
145	.long	Ltmp3-Ltmp2             # Subsection size
146Ltmp2:
147	.short	Ltmp5-Ltmp4             # Record length
148Ltmp4:
149	.short	4412                    # Record kind: S_COMPILE3
150	.long	0                       # Flags and language
151	.short	7                       # CPUType
152	.short	8                       # Frontend version
153	.short	0
154	.short	0
155	.short	0
156	.short	8000                    # Backend version
157	.short	0
158	.short	0
159	.short	0
160	.asciz	"clang version 8.0.0 "  # Null-terminated compiler version string
161Ltmp5:
162Ltmp3:
163	.p2align 2
164	.cv_fpo_data	_realign_with_csrs
165	.long	241                     # Symbol subsection for realign_with_csrs
166	.long	Ltmp7-Ltmp6             # Subsection size
167Ltmp6:
168	.short	Ltmp9-Ltmp8             # Record length
169Ltmp8:
170	.short	4423                    # Record kind: S_GPROC32_ID
171	.long	0                       # PtrParent
172	.long	0                       # PtrEnd
173	.long	0                       # PtrNext
174	.long	Lfunc_end0-_realign_with_csrs # Code size
175	.long	0                       # Offset after prologue
176	.long	0                       # Offset before epilogue
177	.long	0                    # Function type index
178	.secrel32	_realign_with_csrs # Function section relative address
179	.secidx	_realign_with_csrs      # Function section index
180	.byte	0                       # Flags
181	.asciz	"realign_with_csrs"     # Function name
182Ltmp9:
183	.short	Ltmp11-Ltmp10           # Record length
184Ltmp10:
185	.short	4114                    # Record kind: S_FRAMEPROC
186	.long	12                      # FrameSize
187	.long	0                       # Padding
188	.long	0                       # Offset of padding
189	.long	8                       # Bytes of callee saved registers
190	.long	0                       # Exception handler offset
191	.short	0                       # Exception handler section
192	.long	1196032                 # Flags (defines frame register)
193Ltmp11:
194	.short	2                       # Record length
195	.short	4431                    # Record kind: S_PROC_ID_END
196Ltmp7:
197	.p2align	2
198	.cv_filechecksums               # File index to string table offset subsection
199	.cv_stringtable                 # String table
200