1# RUN: llvm-mc < %s -triple=i686-pc-win32 -filetype=obj | llvm-readobj - -codeview | FileCheck %s
2
3# Original source, slightly modified with an extra .cv_loc directive (at EXTRA
4# below) that was causing assertions:
5#
6# void __declspec(noreturn) __declspec(dllimport) exit(int);
7# int unlikely();
8# static inline void do_exit() {
9#   if (unlikely()) {
10#     exit(32);
11#   }
12# }
13# void callit() {
14#   do_exit();
15# }
16
17# We should *not* see t.cpp:6 in the inline line table because we change
18# sections before the next instruction. We should only see t.cpp:5.
19
20# CHECK-LABEL: InlineeSourceLine {
21# CHECK:   Inlinee: do_exit (0x1002)
22# CHECK:   FileID: C:\src\llvm-project\build\t.cpp (0x0)
23# CHECK:   SourceLineNum: 3
24# CHECK: }
25
26# CHECK-LABEL: InlineSiteSym {
27# CHECK:   Kind: S_INLINESITE (0x114D)
28# CHECK:   Inlinee: do_exit (0x1002)
29# CHECK:   BinaryAnnotations [
30# CHECK-NEXT:     ChangeLineOffset: 1
31# CHECK-NEXT:     ChangeCodeLength: 0x9
32# CHECK-NEXT:     ChangeCodeOffsetAndLineOffset: {CodeOffset: 0x1, LineOffset: 1}
33# CHECK-NEXT:     ChangeCodeLength: 0x8
34# CHECK-NEXT:   ]
35# CHECK: }
36
37	.text
38	.def	 _callit; .scl	2; .type	32; .endef
39	.globl	_callit                 # -- Begin function callit
40_callit:                                # @callit
41Lfunc_begin0:
42	.cv_func_id 0
43	.cv_fpo_proc	_callit 0
44# %bb.0:                                # %entry
45	.cv_file	1 "C:\\src\\llvm-project\\build\\t.cpp" "0BC092F354CE14FDC2FA78F8EDE7426E" 1
46	.cv_inline_site_id 1 within 0 inlined_at 1 9 0
47	.cv_loc	1 1 4 0 is_stmt 0       # t.cpp:4:0
48	calll	_unlikely
49	testl	%eax, %eax
50	jne	LBB0_1
51Ltmp0:
52# %bb.2:                                # %do_exit.exit
53	.cv_loc	0 1 10 0                # t.cpp:10:0
54	retl
55LBB0_1:                                 # %if.then.i
56Ltmp1:
57	.cv_loc	1 1 5 0                 # t.cpp:5:0
58	pushl	$32
59	calll	*__imp__exit
60	# EXTRA
61	.cv_loc	1 1 6 0                 # t.cpp:6:0
62Ltmp2:
63	.cv_fpo_endproc
64Lfunc_end0:
65                                        # -- End function
66
67	.section	.debug$S,"dr"
68	.p2align	2
69	.long	4                       # Debug section magic
70	.long	241
71	.long	Ltmp4-Ltmp3             # Subsection size
72Ltmp3:
73	.short	Ltmp6-Ltmp5             # Record length
74Ltmp5:
75	.short	4412                    # Record kind: S_COMPILE3
76	.long	0                       # Flags and language
77	.short	7                       # CPUType
78	.short	7                       # Frontend version
79	.short	0
80	.short	0
81	.short	0
82	.short	7000                    # Backend version
83	.short	0
84	.short	0
85	.short	0
86	.asciz	"clang version 7.0.0 "  # Null-terminated compiler version string
87Ltmp6:
88Ltmp4:
89	.p2align	2
90	.long	246                     # Inlinee lines subsection
91	.long	Ltmp8-Ltmp7             # Subsection size
92Ltmp7:
93	.long	0                       # Inlinee lines signature
94
95                                        # Inlined function do_exit starts at t.cpp:3
96	.long	4098                    # Type index of inlined function
97	.cv_filechecksumoffset	1       # Offset into filechecksum table
98	.long	3                       # Starting line number
99Ltmp8:
100	.p2align	2
101	.cv_fpo_data	_callit
102	.long	241                     # Symbol subsection for callit
103	.long	Ltmp10-Ltmp9            # Subsection size
104Ltmp9:
105	.short	Ltmp12-Ltmp11           # Record length
106Ltmp11:
107	.short	4423                    # Record kind: S_GPROC32_ID
108	.long	0                       # PtrParent
109	.long	0                       # PtrEnd
110	.long	0                       # PtrNext
111	.long	Lfunc_end0-_callit      # Code size
112	.long	0                       # Offset after prologue
113	.long	0                       # Offset before epilogue
114	.long	4099                    # Function type index
115	.secrel32	_callit         # Function section relative address
116	.secidx	_callit                 # Function section index
117	.byte	0                       # Flags
118	.asciz	"callit"                # Function name
119Ltmp12:
120	.short	Ltmp14-Ltmp13           # Record length
121Ltmp13:
122	.short	4429                    # Record kind: S_INLINESITE
123	.long	0                       # PtrParent
124	.long	0                       # PtrEnd
125	.long	4098                    # Inlinee type index
126	.cv_inline_linetable	1 1 3 Lfunc_begin0 Lfunc_end0
127Ltmp14:
128	.short	2                       # Record length
129	.short	4430                    # Record kind: S_INLINESITE_END
130	.short	2                       # Record length
131	.short	4431                    # Record kind: S_PROC_ID_END
132Ltmp10:
133	.p2align	2
134	.cv_linetable	0, _callit, Lfunc_end0
135	.cv_filechecksums               # File index to string table offset subsection
136	.cv_stringtable                 # String table
137	.section	.debug$T,"dr"
138	.p2align	2
139	.long	4                       # Debug section magic
140	# ArgList (0x1000) {
141	#   TypeLeafKind: LF_ARGLIST (0x1201)
142	#   NumArgs: 0
143	#   Arguments [
144	#   ]
145	# }
146	.byte	0x06, 0x00, 0x01, 0x12
147	.byte	0x00, 0x00, 0x00, 0x00
148	# Procedure (0x1001) {
149	#   TypeLeafKind: LF_PROCEDURE (0x1008)
150	#   ReturnType: void (0x3)
151	#   CallingConvention: NearC (0x0)
152	#   FunctionOptions [ (0x0)
153	#   ]
154	#   NumParameters: 0
155	#   ArgListType: () (0x1000)
156	# }
157	.byte	0x0e, 0x00, 0x08, 0x10
158	.byte	0x03, 0x00, 0x00, 0x00
159	.byte	0x00, 0x00, 0x00, 0x00
160	.byte	0x00, 0x10, 0x00, 0x00
161	# FuncId (0x1002) {
162	#   TypeLeafKind: LF_FUNC_ID (0x1601)
163	#   ParentScope: 0x0
164	#   FunctionType: void () (0x1001)
165	#   Name: do_exit
166	# }
167	.byte	0x12, 0x00, 0x01, 0x16
168	.byte	0x00, 0x00, 0x00, 0x00
169	.byte	0x01, 0x10, 0x00, 0x00
170	.byte	0x64, 0x6f, 0x5f, 0x65
171	.byte	0x78, 0x69, 0x74, 0x00
172	# FuncId (0x1003) {
173	#   TypeLeafKind: LF_FUNC_ID (0x1601)
174	#   ParentScope: 0x0
175	#   FunctionType: void () (0x1001)
176	#   Name: callit
177	# }
178	.byte	0x12, 0x00, 0x01, 0x16
179	.byte	0x00, 0x00, 0x00, 0x00
180	.byte	0x01, 0x10, 0x00, 0x00
181	.byte	0x63, 0x61, 0x6c, 0x6c
182	.byte	0x69, 0x74, 0x00, 0xf1
183
184