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