1 ; RUN: llc -filetype=obj %s -o %t.obj
2 ; RUN: llvm-pdbutil dump %t.obj -symbols | FileCheck %s
4 ; A fairly exhaustive test of S_FRAMEPROC flags. Use the source below to compare
5 ; the flags we set with MSVC.
9 ; void *_alloca(size_t);
10 ; struct __declspec(align(16)) _jmp_buf_str {
11 ; unsigned __int64 Part[2];
13 ; typedef struct _jmp_buf_str jmp_buf[16];
14 ; int __cdecl _setjmp(jmp_buf _Buf);
16 ; void may_throw(void);
17 ; void use_intptr(int *);
19 ; void use_alloca(int n) {
20 ; int *p = (int*)_alloca(n * sizeof(int));
25 ; void call_setjmp(int n) {
26 ; if (!_setjmp(g_jbuf))
27 ; use_intptr(nullptr);
30 ; void use_inlineasm() {
41 ; static inline int is_marked_inline(int x, int y) {
44 ; int (*use_inline())(int x, int y) {
45 ; return &is_marked_inline;
55 ; void __declspec(naked) use_naked() {
59 ; void stack_guard() {
61 ; use_intptr(&arr[0]);
65 ; CHECK-LABEL: S_GPROC32_ID [size = 52] `use_alloca`
66 ; CHECK: S_FRAMEPROC [size = 32]
67 ; CHECK: local fp reg = VFRAME, param fp reg = EBP
68 ; CHECK: flags = has alloca | secure checks | opt speed
69 ; CHECK-LABEL: S_GPROC32_ID [size = 52] `call_setjmp`
70 ; CHECK: S_FRAMEPROC [size = 32]
71 ; CHECK: local fp reg = NONE, param fp reg = NONE
72 ; CHECK: flags = has setjmp | opt speed
73 ; CHECK-LABEL: S_GPROC32_ID [size = 56] `use_inlineasm`
74 ; CHECK: S_FRAMEPROC [size = 32]
75 ; CHECK: local fp reg = NONE, param fp reg = NONE
76 ; CHECK: flags = has inline asm | opt speed
77 ; CHECK-LABEL: S_GPROC32_ID [size = 48] `cpp_eh`
78 ; CHECK: S_FRAMEPROC [size = 32]
79 ; CHECK: local fp reg = EBP, param fp reg = EBP
80 ; CHECK: flags = has eh | opt speed
81 ; CHECK-LABEL: S_GPROC32_ID [size = 52] `use_inline`
82 ; CHECK: S_FRAMEPROC [size = 32]
83 ; CHECK: local fp reg = NONE, param fp reg = NONE
84 ; CHECK: flags = opt speed
85 ; CHECK-LABEL: S_LPROC32_ID [size = 56] `is_marked_inline`
86 ; CHECK: S_FRAMEPROC [size = 32]
87 ; CHECK: local fp reg = NONE, param fp reg = NONE
88 ; CHECK: flags = marked inline | opt speed
89 ; CHECK-LABEL: S_GPROC32_ID [size = 44] `seh`
90 ; CHECK: S_FRAMEPROC [size = 32]
91 ; CHECK: local fp reg = EBP, param fp reg = EBP
92 ; CHECK: flags = has seh | opt speed
93 ; CHECK-LABEL: S_LPROC32_ID [size = 56] `?filt$0@0@seh@@`
94 ; CHECK: S_FRAMEPROC [size = 32]
95 ; CHECK: local fp reg = EBP, param fp reg = EBP
96 ; CHECK: flags = opt speed
97 ; CHECK-LABEL: S_GPROC32_ID [size = 52] `use_naked`
98 ; CHECK: S_FRAMEPROC [size = 32]
99 ; CHECK: local fp reg = NONE, param fp reg = NONE
100 ; CHECK: flags = has inline asm | naked | opt speed
101 ; CHECK-LABEL: S_GPROC32_ID [size = 52] `stack_guard`
102 ; CHECK: S_FRAMEPROC [size = 32]
103 ; CHECK: local fp reg = VFRAME, param fp reg = EBP
104 ; CHECK: flags = secure checks | opt speed
106 ; ModuleID = 'frameproc-flags.cpp'
107 source_filename = "frameproc-flags.cpp"
108 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
109 target triple = "i386-pc-windows-msvc19.14.26433"
111 %struct._jmp_buf_str = type { [2 x i64] }
113 @g_jbuf = dso_local global [16 x %struct._jmp_buf_str] zeroinitializer, align 16, !dbg !0
115 define dso_local void @use_alloca(i32 %n) local_unnamed_addr #0 !dbg !25 {
117 call void @llvm.dbg.value(metadata i32 %n, metadata !29, metadata !DIExpression()), !dbg !31
118 %mul = shl i32 %n, 2, !dbg !32
119 %0 = alloca i8, i32 %mul, align 16, !dbg !32
120 %1 = bitcast i8* %0 to i32*, !dbg !32
121 call void @llvm.dbg.value(metadata i32* %1, metadata !30, metadata !DIExpression()), !dbg !32
122 call void @use_intptr(i32* nonnull %1), !dbg !33
126 ; Function Attrs: nounwind readnone speculatable
127 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
129 ; Function Attrs: argmemonly nounwind
130 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #2
132 declare dso_local void @use_intptr(i32*) local_unnamed_addr #3
134 ; Function Attrs: argmemonly nounwind
135 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #2
137 define dso_local void @call_setjmp(i32 %n) local_unnamed_addr #0 !dbg !35 {
139 call void @llvm.dbg.value(metadata i32 %n, metadata !37, metadata !DIExpression()), !dbg !38
140 %0 = call i32 (i8*, i32, ...) @_setjmp3(i8* bitcast ([16 x %struct._jmp_buf_str]* @g_jbuf to i8*), i32 0) #4, !dbg !39
141 %tobool = icmp eq i32 %0, 0, !dbg !39
142 br i1 %tobool, label %if.then, label %if.end, !dbg !39
144 if.then: ; preds = %entry
145 call void @use_intptr(i32* null), !dbg !40
146 br label %if.end, !dbg !40
148 if.end: ; preds = %entry, %if.then
152 ; Function Attrs: returns_twice
153 declare dso_local i32 @_setjmp3(i8*, i32, ...) local_unnamed_addr #4
155 ; Function Attrs: nounwind
156 define dso_local void @use_inlineasm() local_unnamed_addr #5 !dbg !43 {
158 tail call void asm sideeffect inteldialect "nop", "~{dirflag},~{fpsr},~{flags}"() #10, !dbg !46, !srcloc !47
162 define dso_local void @cpp_eh() local_unnamed_addr #0 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) !dbg !49 {
164 invoke void @may_throw()
165 to label %try.cont unwind label %catch.dispatch, !dbg !50
167 catch.dispatch: ; preds = %entry
168 %0 = catchswitch within none [label %catch] unwind to caller, !dbg !52
170 catch: ; preds = %catch.dispatch
171 %1 = catchpad within %0 [i8* null, i32 64, i8* null], !dbg !52
172 catchret from %1 to label %try.cont, !dbg !53
174 try.cont: ; preds = %entry, %catch
178 declare dso_local void @may_throw() local_unnamed_addr #3
180 declare dso_local i32 @__CxxFrameHandler3(...)
182 ; Function Attrs: norecurse nounwind readnone
183 define dso_local nonnull i32 (i32, i32)* @use_inline() local_unnamed_addr #6 !dbg !56 {
185 ret i32 (i32, i32)* @"?is_marked_inline@@YAHHH@Z", !dbg !62
188 ; Function Attrs: inlinehint nounwind readnone
189 define internal i32 @"?is_marked_inline@@YAHHH@Z"(i32 %x, i32 %y) #7 !dbg !63 {
191 call void @llvm.dbg.value(metadata i32 %y, metadata !65, metadata !DIExpression()), !dbg !67
192 call void @llvm.dbg.value(metadata i32 %x, metadata !66, metadata !DIExpression()), !dbg !67
193 %add = add nsw i32 %y, %x, !dbg !68
194 ret i32 %add, !dbg !68
197 define dso_local void @seh() #0 personality i8* bitcast (i32 (...)* @_except_handler3 to i8*) !dbg !69 {
199 %__exception_code = alloca i32, align 4
200 call void (...) @llvm.localescape(i32* nonnull %__exception_code)
201 invoke void @may_throw() #12
202 to label %__try.cont unwind label %catch.dispatch, !dbg !70
204 catch.dispatch: ; preds = %entry
205 %0 = catchswitch within none [label %__except.ret] unwind to caller, !dbg !72
207 __except.ret: ; preds = %catch.dispatch
208 %1 = catchpad within %0 [i8* bitcast (i32 ()* @"?filt$0@0@seh@@" to i8*)], !dbg !72
209 catchret from %1 to label %__try.cont, !dbg !72
211 __try.cont: ; preds = %entry, %__except.ret
215 ; Function Attrs: nounwind
216 define internal i32 @"?filt$0@0@seh@@"() #8 !dbg !74 {
218 %0 = tail call i8* @llvm.frameaddress(i32 1)
219 %1 = tail call i8* @llvm.eh.recoverfp(i8* bitcast (void ()* @seh to i8*), i8* %0)
220 %2 = tail call i8* @llvm.localrecover(i8* bitcast (void ()* @seh to i8*), i8* %1, i32 0)
221 %__exception_code = bitcast i8* %2 to i32*
222 %3 = getelementptr inbounds i8, i8* %0, i32 -20, !dbg !76
223 %4 = bitcast i8* %3 to { i32*, i8* }**, !dbg !76
224 %5 = load { i32*, i8* }*, { i32*, i8* }** %4, align 4, !dbg !76
225 %6 = getelementptr inbounds { i32*, i8* }, { i32*, i8* }* %5, i32 0, i32 0, !dbg !76
226 %7 = load i32*, i32** %6, align 4, !dbg !76
227 %8 = load i32, i32* %7, align 4, !dbg !76
228 store i32 %8, i32* %__exception_code, align 4, !dbg !76
232 ; Function Attrs: nounwind readnone
233 declare i8* @llvm.frameaddress(i32) #9
235 ; Function Attrs: nounwind readnone
236 declare i8* @llvm.eh.recoverfp(i8*, i8*) #9
238 ; Function Attrs: nounwind readnone
239 declare i8* @llvm.localrecover(i8*, i8*, i32) #9
241 declare dso_local i32 @_except_handler3(...)
243 ; Function Attrs: nounwind
244 declare void @llvm.localescape(...) #10
246 ; Function Attrs: naked noinline nounwind
247 define dso_local void @use_naked() #11 !dbg !77 {
249 tail call void asm sideeffect inteldialect "ret", "~{dirflag},~{fpsr},~{flags}"() #10, !dbg !78, !srcloc !79
250 unreachable, !dbg !80
253 define dso_local void @stack_guard() local_unnamed_addr #0 !dbg !81 {
255 %arr = alloca [12 x i32], align 4
256 %0 = bitcast [12 x i32]* %arr to i8*, !dbg !87
257 call void @llvm.lifetime.start.p0i8(i64 48, i8* nonnull %0) #10, !dbg !87
258 call void @llvm.dbg.declare(metadata [12 x i32]* %arr, metadata !83, metadata !DIExpression()), !dbg !87
259 call void @llvm.memset.p0i8.i32(i8* nonnull align 4 %0, i8 0, i32 48, i1 false), !dbg !87
260 %arrayidx = getelementptr inbounds [12 x i32], [12 x i32]* %arr, i32 0, i32 0, !dbg !88
261 call void @use_intptr(i32* nonnull %arrayidx), !dbg !88
262 call void @llvm.lifetime.end.p0i8(i64 48, i8* nonnull %0) #10, !dbg !89
266 ; Function Attrs: argmemonly nounwind
267 declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i1) #2
269 ; Function Attrs: nounwind readnone speculatable
270 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
272 attributes #0 = { sspstrong "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
273 attributes #1 = { nounwind readnone speculatable }
274 attributes #2 = { argmemonly nounwind }
275 attributes #3 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
276 attributes #4 = { returns_twice }
277 attributes #5 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
278 attributes #6 = { norecurse nounwind readnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
279 attributes #7 = { inlinehint nounwind readnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
280 attributes #8 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
281 attributes #9 = { nounwind readnone }
282 attributes #10 = { nounwind }
283 attributes #11 = { naked noinline nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
284 attributes #12 = { noinline }
287 !llvm.module.flags = !{!20, !21, !22, !23}
290 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
291 !1 = distinct !DIGlobalVariable(name: "g_jbuf", scope: !2, file: !3, line: 18, type: !9, isLocal: false, isDefinition: true)
292 !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 8.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !5, globals: !8, nameTableKind: None)
293 !3 = !DIFile(filename: "frameproc-flags.cpp", directory: "C:\5Csrc\5Cllvm-project\5Cbuild", checksumkind: CSK_MD5, checksum: "1dd66a71668512c95552767c3a35300a")
296 !6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 32)
297 !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
299 !9 = !DIDerivedType(tag: DW_TAG_typedef, name: "jmp_buf", file: !3, line: 7, baseType: !10)
300 !10 = !DICompositeType(tag: DW_TAG_array_type, baseType: !11, size: 2048, elements: !18)
301 !11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_jmp_buf_str", file: !3, line: 4, size: 128, align: 128, flags: DIFlagTypePassByValue, elements: !12, identifier: ".?AU_jmp_buf_str@@")
303 !13 = !DIDerivedType(tag: DW_TAG_member, name: "Part", scope: !11, file: !3, line: 5, baseType: !14, size: 128)
304 !14 = !DICompositeType(tag: DW_TAG_array_type, baseType: !15, size: 128, elements: !16)
305 !15 = !DIBasicType(name: "long long unsigned int", size: 64, encoding: DW_ATE_unsigned)
307 !17 = !DISubrange(count: 2)
309 !19 = !DISubrange(count: 16)
310 !20 = !{i32 1, !"NumRegisterParameters", i32 0}
311 !21 = !{i32 2, !"CodeView", i32 1}
312 !22 = !{i32 2, !"Debug Info Version", i32 3}
313 !23 = !{i32 1, !"wchar_size", i32 2}
314 !24 = !{!"clang version 8.0.0 "}
315 !25 = distinct !DISubprogram(name: "use_alloca", scope: !3, file: !3, line: 13, type: !26, isLocal: false, isDefinition: true, scopeLine: 13, flags: DIFlagPrototyped, isOptimized: true, unit: !2, retainedNodes: !28)
316 !26 = !DISubroutineType(types: !27)
319 !29 = !DILocalVariable(name: "n", arg: 1, scope: !25, file: !3, line: 13, type: !7)
320 !30 = !DILocalVariable(name: "p", scope: !25, file: !3, line: 14, type: !6)
321 !31 = !DILocation(line: 13, scope: !25)
322 !32 = !DILocation(line: 14, scope: !25)
323 !33 = !DILocation(line: 15, scope: !25)
324 !34 = !DILocation(line: 16, scope: !25)
325 !35 = distinct !DISubprogram(name: "call_setjmp", scope: !3, file: !3, line: 19, type: !26, isLocal: false, isDefinition: true, scopeLine: 19, flags: DIFlagPrototyped, isOptimized: true, unit: !2, retainedNodes: !36)
327 !37 = !DILocalVariable(name: "n", arg: 1, scope: !35, file: !3, line: 19, type: !7)
328 !38 = !DILocation(line: 19, scope: !35)
329 !39 = !DILocation(line: 20, scope: !35)
330 !40 = !DILocation(line: 21, scope: !41)
331 !41 = distinct !DILexicalBlock(scope: !35, file: !3, line: 20)
332 !42 = !DILocation(line: 22, scope: !35)
333 !43 = distinct !DISubprogram(name: "use_inlineasm", scope: !3, file: !3, line: 24, type: !44, isLocal: false, isDefinition: true, scopeLine: 24, flags: DIFlagPrototyped, isOptimized: true, unit: !2, retainedNodes: !4)
334 !44 = !DISubroutineType(types: !45)
336 !46 = !DILocation(line: 25, scope: !43)
338 !48 = !DILocation(line: 26, scope: !43)
339 !49 = distinct !DISubprogram(name: "cpp_eh", scope: !3, file: !3, line: 28, type: !44, isLocal: false, isDefinition: true, scopeLine: 28, flags: DIFlagPrototyped, isOptimized: true, unit: !2, retainedNodes: !4)
340 !50 = !DILocation(line: 30, scope: !51)
341 !51 = distinct !DILexicalBlock(scope: !49, file: !3, line: 29)
342 !52 = !DILocation(line: 31, scope: !51)
343 !53 = !DILocation(line: 32, scope: !54)
344 !54 = distinct !DILexicalBlock(scope: !49, file: !3, line: 31)
345 !55 = !DILocation(line: 33, scope: !49)
346 !56 = distinct !DISubprogram(name: "use_inline", scope: !3, file: !3, line: 38, type: !57, isLocal: false, isDefinition: true, scopeLine: 38, flags: DIFlagPrototyped, isOptimized: true, unit: !2, retainedNodes: !4)
347 !57 = !DISubroutineType(types: !58)
349 !59 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !60, size: 32)
350 !60 = !DISubroutineType(types: !61)
352 !62 = !DILocation(line: 39, scope: !56)
353 !63 = distinct !DISubprogram(name: "is_marked_inline", linkageName: "?is_marked_inline@@YAHHH@Z", scope: !3, file: !3, line: 35, type: !60, isLocal: true, isDefinition: true, scopeLine: 35, flags: DIFlagPrototyped, isOptimized: true, unit: !2, retainedNodes: !64)
355 !65 = !DILocalVariable(name: "y", arg: 2, scope: !63, file: !3, line: 35, type: !7)
356 !66 = !DILocalVariable(name: "x", arg: 1, scope: !63, file: !3, line: 35, type: !7)
357 !67 = !DILocation(line: 35, scope: !63)
358 !68 = !DILocation(line: 36, scope: !63)
359 !69 = distinct !DISubprogram(name: "seh", scope: !3, file: !3, line: 42, type: !44, isLocal: false, isDefinition: true, scopeLine: 42, flags: DIFlagPrototyped, isOptimized: true, unit: !2, retainedNodes: !4)
360 !70 = !DILocation(line: 44, scope: !71)
361 !71 = distinct !DILexicalBlock(scope: !69, file: !3, line: 43)
362 !72 = !DILocation(line: 45, scope: !71)
363 !73 = !DILocation(line: 47, scope: !69)
364 !74 = distinct !DISubprogram(linkageName: "?filt$0@0@seh@@", scope: !3, file: !3, line: 45, type: !75, isLocal: true, isDefinition: true, scopeLine: 45, flags: DIFlagArtificial, isOptimized: true, unit: !2, retainedNodes: !4)
365 !75 = !DISubroutineType(types: !4)
366 !76 = !DILocation(line: 45, scope: !74)
367 !77 = distinct !DISubprogram(name: "use_naked", scope: !3, file: !3, line: 49, type: !44, isLocal: false, isDefinition: true, scopeLine: 49, flags: DIFlagPrototyped, isOptimized: true, unit: !2, retainedNodes: !4)
368 !78 = !DILocation(line: 50, scope: !77)
370 !80 = !DILocation(line: 51, scope: !77)
371 !81 = distinct !DISubprogram(name: "stack_guard", scope: !3, file: !3, line: 53, type: !44, isLocal: false, isDefinition: true, scopeLine: 53, flags: DIFlagPrototyped, isOptimized: true, unit: !2, retainedNodes: !82)
373 !83 = !DILocalVariable(name: "arr", scope: !81, file: !3, line: 54, type: !84)
374 !84 = !DICompositeType(tag: DW_TAG_array_type, baseType: !7, size: 384, elements: !85)
376 !86 = !DISubrange(count: 12)
377 !87 = !DILocation(line: 54, scope: !81)
378 !88 = !DILocation(line: 55, scope: !81)
379 !89 = !DILocation(line: 56, scope: !81)