• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj %s -o %t.obj -triple x86_64-windows-msvc
3# RUN: lld-link -entry:main -nodefaultlib %t.obj -out:%t.exe -pdb:%t.pdb -debug
4# RUN: llvm-symbolizer --obj=%t.exe --relative-address \
5# RUN:   0x1014 0x1018 0x101c 0x1023 0x1024 \
6# RUN:   0x1037 0x103A 0x104B 0x104E | FileCheck %s
7
8# Compiled from this cpp code, with modifications to add extra inline line and
9# file changes:
10# clang -cc1 -triple x86_64-windows-msvc -gcodeview -S test.cpp
11#
12# __attribute__((always_inline)) int inlinee_2(int x) {
13#   return x + 1;
14# }
15# __attribute__((always_inline)) int inlinee_1(int x) {
16#   return inlinee_2(x) + 2;
17# }
18# int main() {
19#   int x = inlinee_1(33);
20#   int y = inlinee_2(22);
21#   int z = inlinee_2(11);
22#   return x + y + z;
23# }
24
25	.text
26	.def	 @feat.00;
27	.scl	3;
28	.type	0;
29	.endef
30	.globl	@feat.00
31.set @feat.00, 0
32	.file	"test.cpp"
33	.def	 main;
34	.scl	2;
35	.type	32;
36	.endef
37	.globl	main                            # -- Begin function main
38	.p2align	4, 0x90
39main:                                   # @main
40.Lfunc_begin0:
41	.cv_func_id 0
42	.cv_file	1 "C:\\src\\test.cpp" "67680A954FC00F980188190C8D23C68E" 1
43  .cv_file  2 "C:\\src\\fakefile.cpp" "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" 1
44	.cv_loc	0 1 9 0                         # test.cpp:9:0
45# %bb.0:                                # %entry
46	subq	$32, %rsp
47	movl	$0, 12(%rsp)
48	movl	$33, 16(%rsp)
49.Ltmp0:
50	.cv_inline_site_id 1 within 0 inlined_at 1 10 11
51	.cv_loc	1 1 6 20                        # test.cpp:6:20
52
53# CHECK: inlinee_1
54# CHECK-NEXT: C:\src\test.cpp:6:0
55# CHECK-NEXT: main
56# CHECK-NEXT: C:\src\test.cpp:10:11
57	movl	16(%rsp), %eax
58
59# Add a line change here.
60  .cv_loc 1 1 7 7
61
62# CHECK: inlinee_1
63# CHECK-NEXT: C:\src\test.cpp:7:0
64# CHECK-NEXT: main
65# CHECK-NEXT: C:\src\test.cpp:10:11
66	movl	%eax, 20(%rsp)
67.Ltmp1:
68	.cv_inline_site_id 2 within 1 inlined_at 1 6 10
69	.cv_loc	2 1 2 10                        # test.cpp:2:10
70
71# CHECK: inlinee_2
72# CHECK-NEXT: C:\src\test.cpp:2:0
73# CHECK-NEXT: inlinee_1
74# CHECK-NEXT: C:\src\test.cpp:6:0
75# CHECK-NEXT: main
76# CHECK-NEXT: C:\src\test.cpp:10:11
77	movl	20(%rsp), %eax
78	.cv_loc	2 1 2 12                        # test.cpp:2:12
79	addl	$1, %eax
80
81# Add a file change.
82  .cv_loc 2 2 102 0                       # fakefile.cpp:102:0
83
84# CHECK: inlinee_2
85# CHECK-NEXT: C:\src\fakefile.cpp:102:0
86# CHECK-NEXT: inlinee_1
87# CHECK-NEXT: C:\src\test.cpp:6:0
88# CHECK-NEXT: main
89# CHECK-NEXT: C:\src\test.cpp:10:11
90  nop
91
92.Ltmp2:
93	.cv_loc	1 1 6 23                        # test.cpp:6:23
94
95# CHECK: inlinee_1
96# CHECK-NEXT: C:\src\test.cpp:6:0
97# CHECK-NEXT: main
98# CHECK-NEXT: C:\src\test.cpp:10:11
99	addl	$2, %eax
100.Ltmp3:
101	.cv_loc	0 1 10 7                        # test.cpp:10:7
102	movl	%eax, 8(%rsp)
103	movl	$22, 28(%rsp)
104.Ltmp4:
105# Add a .cv_loc 0 so there is a gap in the inline site.
106# CHECK: main
107# CHECK-NEXT: C:\src\test.cpp:0:0
108
109# CHECK: inlinee_2
110# CHECK-NEXT: C:\src\test.cpp:2:0
111# CHECK-NEXT: main
112# CHECK-NEXT: C:\src\test.cpp:11:11
113	.cv_inline_site_id 3 within 0 inlined_at 1 11 11
114	.cv_loc	3 1 2 10                        # test.cpp:2:10
115	movl	28(%rsp), %eax
116  .cv_loc 0 1 0 0
117  nop
118	.cv_loc	3 1 2 12                        # test.cpp:2:12
119	addl	$1, %eax
120.Ltmp5:
121	.cv_loc	0 1 11 7                        # test.cpp:11:7
122	movl	%eax, 4(%rsp)
123	movl	$11, 24(%rsp)
124.Ltmp6:
125# Same test as above but modify the .cv_inline_linetable to use an annotation
126# that clang doesn't emit.
127# CHECK-NOT: inlinee_2
128# CHECK: main
129# CHECK-NEXT: C:\src\test.cpp:11:7
130
131# CHECK: inlinee_2
132# CHECK-NEXT: C:\src\test.cpp:1:0
133# CHECK-NEXT: main
134# CHECK-NEXT: C:\src\test.cpp:11:7
135.cv_inline_site_id 4 within 0 inlined_at 1 0 0
136	movl	24(%rsp), %eax
137  nop
138	addl	$1, %eax
139.Ltmp7:
140	.cv_loc	0 1 13 3                        # test.cpp:13:3
141	addq	$32, %rsp
142	retq
143.Ltmp8:
144.Lfunc_end0:
145                                        # -- End function
146	.section	.debug$S,"dr"
147	.p2align	2
148	.long	4                               # Debug section magic
149	.long	241
150	.long	.Ltmp10-.Ltmp9                  # Subsection size
151.Ltmp9:
152	.short	.Ltmp12-.Ltmp11                 # Record length
153.Ltmp11:
154	.short	4412                            # Record kind: S_COMPILE3
155	.long	1                               # Flags and language
156	.short	208                             # CPUType
157	.short	12                              # Frontend version
158	.short	0
159	.short	0
160	.short	0
161	.short	12000                           # Backend version
162	.short	0
163	.short	0
164	.short	0
165	.asciz	"clang version 12.0.0 (https://github.com/llvm/llvm-project.git 2ef947fe318d081b12add3d411bbb2af6373c66d)" # Null-terminated compiler version string
166	.p2align	2
167.Ltmp12:
168.Ltmp10:
169	.p2align	2
170	.long	246                             # Inlinee lines subsection
171	.long	.Ltmp14-.Ltmp13                 # Subsection size
172.Ltmp13:
173	.long	0                               # Inlinee lines signature
174
175                                        # Inlined function inlinee_1 starts at test.cpp:5
176	.long	4098                            # Type index of inlined function
177	.cv_filechecksumoffset	1               # Offset into filechecksum table
178	.long	5                               # Starting line number
179
180                                        # Inlined function inlinee_2 starts at test.cpp:1
181	.long	4099                            # Type index of inlined function
182	.cv_filechecksumoffset	1               # Offset into filechecksum table
183	.long	1                               # Starting line number
184.Ltmp14:
185	.p2align	2
186	.long	241                             # Symbol subsection for main
187	.long	.Ltmp16-.Ltmp15                 # Subsection size
188.Ltmp15:
189	.short	.Ltmp18-.Ltmp17                 # Record length
190.Ltmp17:
191	.short	4423                            # Record kind: S_GPROC32_ID
192	.long	0                               # PtrParent
193	.long	0                               # PtrEnd
194	.long	0                               # PtrNext
195	.long	.Lfunc_end0-main                # Code size
196	.long	0                               # Offset after prologue
197	.long	0                               # Offset before epilogue
198	.long	4102                            # Function type index
199	.secrel32	main                    # Function section relative address
200	.secidx	main                            # Function section index
201	.byte	0                               # Flags
202	.asciz	"main"                          # Function name
203	.p2align	2
204.Ltmp18:
205	.short	.Ltmp20-.Ltmp19                 # Record length
206.Ltmp19:
207	.short	4114                            # Record kind: S_FRAMEPROC
208	.long	32                              # FrameSize
209	.long	0                               # Padding
210	.long	0                               # Offset of padding
211	.long	0                               # Bytes of callee saved registers
212	.long	0                               # Exception handler offset
213	.short	0                               # Exception handler section
214	.long	81920                           # Flags (defines frame register)
215	.p2align	2
216.Ltmp20:
217	.short	.Ltmp22-.Ltmp21                 # Record length
218.Ltmp21:
219	.short	4414                            # Record kind: S_LOCAL
220	.long	116                             # TypeIndex
221	.short	0                               # Flags
222	.asciz	"x"
223	.p2align	2
224.Ltmp22:
225	.cv_def_range	 .Ltmp0 .Ltmp8, frame_ptr_rel, 8
226	.short	.Ltmp24-.Ltmp23                 # Record length
227.Ltmp23:
228	.short	4414                            # Record kind: S_LOCAL
229	.long	116                             # TypeIndex
230	.short	0                               # Flags
231	.asciz	"y"
232	.p2align	2
233.Ltmp24:
234	.cv_def_range	 .Ltmp0 .Ltmp8, frame_ptr_rel, 4
235	.short	.Ltmp26-.Ltmp25                 # Record length
236.Ltmp25:
237	.short	4414                            # Record kind: S_LOCAL
238	.long	116                             # TypeIndex
239	.short	0                               # Flags
240	.asciz	"z"
241	.p2align	2
242.Ltmp26:
243	.cv_def_range	 .Ltmp0 .Ltmp8, frame_ptr_rel, 0
244	.short	.Ltmp28-.Ltmp27                 # Record length
245.Ltmp27:
246	.short	4429                            # Record kind: S_INLINESITE
247	.long	0                               # PtrParent
248	.long	0                               # PtrEnd
249	.long	4098                            # Inlinee type index
250	.cv_inline_linetable	1 1 5 .Lfunc_begin0 .Lfunc_end0
251	.p2align	2
252.Ltmp28:
253	.short	.Ltmp30-.Ltmp29                 # Record length
254.Ltmp29:
255	.short	4414                            # Record kind: S_LOCAL
256	.long	116                             # TypeIndex
257	.short	1                               # Flags
258	.asciz	"x"
259	.p2align	2
260.Ltmp30:
261	.cv_def_range	 .Ltmp0 .Ltmp3, frame_ptr_rel, 16
262	.short	.Ltmp32-.Ltmp31                 # Record length
263.Ltmp31:
264	.short	4429                            # Record kind: S_INLINESITE
265	.long	0                               # PtrParent
266	.long	0                               # PtrEnd
267	.long	4099                            # Inlinee type index
268	.cv_inline_linetable	2 1 1 .Lfunc_begin0 .Lfunc_end0
269	.p2align	2
270.Ltmp32:
271	.short	.Ltmp34-.Ltmp33                 # Record length
272.Ltmp33:
273	.short	4414                            # Record kind: S_LOCAL
274	.long	116                             # TypeIndex
275	.short	1                               # Flags
276	.asciz	"x"
277	.p2align	2
278.Ltmp34:
279	.cv_def_range	 .Ltmp1 .Ltmp2, frame_ptr_rel, 20
280	.short	2                               # Record length
281	.short	4430                            # Record kind: S_INLINESITE_END
282	.short	2                               # Record length
283	.short	4430                            # Record kind: S_INLINESITE_END
284	.short	.Ltmp36-.Ltmp35                 # Record length
285.Ltmp35:
286	.short	4429                            # Record kind: S_INLINESITE
287	.long	0                               # PtrParent
288	.long	0                               # PtrEnd
289	.long	4099                            # Inlinee type index
290	.cv_inline_linetable	3 1 1 .Lfunc_begin0 .Lfunc_end0
291	.p2align	2
292.Ltmp36:
293	.short	.Ltmp38-.Ltmp37                 # Record length
294.Ltmp37:
295	.short	4414                            # Record kind: S_LOCAL
296	.long	116                             # TypeIndex
297	.short	1                               # Flags
298	.asciz	"x"
299	.p2align	2
300.Ltmp38:
301	.cv_def_range	 .Ltmp4 .Ltmp5, frame_ptr_rel, 28
302	.short	2                               # Record length
303	.short	4430                            # Record kind: S_INLINESITE_END
304	.short	.Ltmp40-.Ltmp39                 # Record length
305.Ltmp39:
306	.short	4429                            # Record kind: S_INLINESITE
307	.long	0                               # PtrParent
308	.long	0                               # PtrEnd
309	.long	4099                            # Inlinee type index
310# Changed inline line table annotations.
311  .byte 0x0C, 0x4, 0x47
312  .byte 0x0C, 0x3, 0x5
313	.p2align	2
314.Ltmp40:
315	.short	.Ltmp42-.Ltmp41                 # Record length
316.Ltmp41:
317	.short	4414                            # Record kind: S_LOCAL
318	.long	116                             # TypeIndex
319	.short	1                               # Flags
320	.asciz	"x"
321	.p2align	2
322.Ltmp42:
323	.cv_def_range	 .Ltmp6 .Ltmp7, frame_ptr_rel, 24
324	.short	2                               # Record length
325	.short	4430                            # Record kind: S_INLINESITE_END
326	.short	2                               # Record length
327	.short	4431                            # Record kind: S_PROC_ID_END
328.Ltmp16:
329	.p2align	2
330	.cv_linetable	0, main, .Lfunc_end0
331	.cv_filechecksums                       # File index to string table offset subsection
332	.cv_stringtable                         # String table
333	.long	241
334	.long	.Ltmp44-.Ltmp43                 # Subsection size
335.Ltmp43:
336	.short	.Ltmp46-.Ltmp45                 # Record length
337.Ltmp45:
338	.short	4428                            # Record kind: S_BUILDINFO
339	.long	4105                            # LF_BUILDINFO index
340	.p2align	2
341.Ltmp46:
342.Ltmp44:
343	.p2align	2
344	.section	.debug$T,"dr"
345	.p2align	2
346	.long	4                               # Debug section magic
347	# ArgList (0x1000)
348	.short	0xa                             # Record length
349	.short	0x1201                          # Record kind: LF_ARGLIST
350	.long	0x1                             # NumArgs
351	.long	0x74                            # Argument: int
352	# Procedure (0x1001)
353	.short	0xe                             # Record length
354	.short	0x1008                          # Record kind: LF_PROCEDURE
355	.long	0x74                            # ReturnType: int
356	.byte	0x0                             # CallingConvention: NearC
357	.byte	0x0                             # FunctionOptions
358	.short	0x1                             # NumParameters
359	.long	0x1000                          # ArgListType: (int)
360	# FuncId (0x1002)
361	.short	0x16                            # Record length
362	.short	0x1601                          # Record kind: LF_FUNC_ID
363	.long	0x0                             # ParentScope
364	.long	0x1001                          # FunctionType: int (int)
365	.asciz	"inlinee_1"                     # Name
366	.byte	242
367	.byte	241
368	# FuncId (0x1003)
369	.short	0x16                            # Record length
370	.short	0x1601                          # Record kind: LF_FUNC_ID
371	.long	0x0                             # ParentScope
372	.long	0x1001                          # FunctionType: int (int)
373	.asciz	"inlinee_2"                     # Name
374	.byte	242
375	.byte	241
376	# ArgList (0x1004)
377	.short	0x6                             # Record length
378	.short	0x1201                          # Record kind: LF_ARGLIST
379	.long	0x0                             # NumArgs
380	# Procedure (0x1005)
381	.short	0xe                             # Record length
382	.short	0x1008                          # Record kind: LF_PROCEDURE
383	.long	0x74                            # ReturnType: int
384	.byte	0x0                             # CallingConvention: NearC
385	.byte	0x0                             # FunctionOptions
386	.short	0x0                             # NumParameters
387	.long	0x1004                          # ArgListType: ()
388	# FuncId (0x1006)
389	.short	0x12                            # Record length
390	.short	0x1601                          # Record kind: LF_FUNC_ID
391	.long	0x0                             # ParentScope
392	.long	0x1005                          # FunctionType: int ()
393	.asciz	"main"                          # Name
394	.byte	243
395	.byte	242
396	.byte	241
397	# StringId (0x1007)
398	.short	0x2a                            # Record length
399	.short	0x1605                          # Record kind: LF_STRING_ID
400	.long	0x0                             # Id
401	.asciz	"C:\\src\\tests\\symbolizer\\asm-test"  # StringData
402	.byte	243
403	.byte	242
404	.byte	241
405	# StringId (0x1008)
406	.short	0xe                             # Record length
407	.short	0x1605                          # Record kind: LF_STRING_ID
408	.long	0x0                             # Id
409	.asciz	"<stdin>"                       # StringData
410	# BuildInfo (0x1009)
411	.short	0x1a                            # Record length
412	.short	0x1603                          # Record kind: LF_BUILDINFO
413	.short	0x5                             # NumArgs
414	.long	0x1007                          # Argument: C:\src
415	.long	0x0                             # Argument
416	.long	0x1008                          # Argument: <stdin>
417	.long	0x0                             # Argument
418	.long	0x0                             # Argument
419	.byte	242
420	.byte	241
421