xref: /llvm-project/llvm/test/DebugInfo/COFF/fpo-stack-protect.ll (revision 5a288fa32e0c91b211e39f3e370255916902f898)
1; RUN: llc < %s -experimental-debug-variable-locations=true | FileCheck %s
2
3; C source:
4; void escape(int *);
5; int ssp(int a) {
6;   int arr[4] = {a, a, a, a};
7;   escape(&arr[0]);
8;   return a;
9; }
10
11; CHECK: _ssp:                                   # @ssp
12; CHECK:         .cv_fpo_proc    _ssp 4
13; CHECK:         pushl   %esi
14; CHECK:         .cv_fpo_pushreg %esi
15; CHECK:         subl    $20, %esp
16; CHECK:         .cv_fpo_stackalloc      20
17; CHECK:         .cv_fpo_endprologue
18; CHECK:         ___security_cookie
19
20; CHECK:         movl    28(%esp), %esi
21; CHECK:         movl    %esi, {{[0-9]*}}(%esp)
22; CHECK:         movl    %esi, {{[0-9]*}}(%esp)
23; CHECK:         movl    %esi, {{[0-9]*}}(%esp)
24; CHECK:         movl    %esi, {{[0-9]*}}(%esp)
25
26; CHECK:         calll   _escape
27; CHECK:         calll   @__security_check_cookie@4
28
29; CHECK:         movl    %esi, %eax
30; CHECK:         addl    $20, %esp
31; CHECK:         popl    %esi
32; CHECK:         retl
33; CHECK: Ltmp4:
34; CHECK:         .cv_fpo_endproc
35
36; ModuleID = 't.c'
37source_filename = "t.c"
38target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
39target triple = "i386-pc-windows-msvc19.11.25508"
40
41; Function Attrs: nounwind sspstrong
42define i32 @ssp(i32 returned %a) local_unnamed_addr #0 !dbg !8 {
43entry:
44  %arr = alloca [4 x i32], align 4
45  tail call void @llvm.dbg.value(metadata i32 %a, metadata !13, metadata !DIExpression()), !dbg !18
46  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %arr) #4, !dbg !19
47  tail call void @llvm.dbg.declare(metadata ptr %arr, metadata !14, metadata !DIExpression()), !dbg !20
48  store i32 %a, ptr %arr, align 4, !dbg !21, !tbaa !22
49  %arrayinit.element = getelementptr inbounds [4 x i32], ptr %arr, i32 0, i32 1, !dbg !21
50  store i32 %a, ptr %arrayinit.element, align 4, !dbg !21, !tbaa !22
51  %arrayinit.element1 = getelementptr inbounds [4 x i32], ptr %arr, i32 0, i32 2, !dbg !21
52  store i32 %a, ptr %arrayinit.element1, align 4, !dbg !21, !tbaa !22
53  %arrayinit.element2 = getelementptr inbounds [4 x i32], ptr %arr, i32 0, i32 3, !dbg !21
54  store i32 %a, ptr %arrayinit.element2, align 4, !dbg !21, !tbaa !22
55  call void @escape(ptr nonnull %arr) #4, !dbg !26
56  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %arr) #4, !dbg !27
57  ret i32 %a, !dbg !28
58}
59
60; Function Attrs: nounwind readnone speculatable
61declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
62
63; Function Attrs: argmemonly nounwind
64declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #2
65
66declare void @escape(ptr) local_unnamed_addr #3
67
68; Function Attrs: argmemonly nounwind
69declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #2
70
71; Function Attrs: nounwind readnone speculatable
72declare void @llvm.dbg.value(metadata, metadata, metadata) #1
73
74attributes #0 = { nounwind sspstrong "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "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" }
75attributes #1 = { nounwind readnone speculatable }
76attributes #2 = { argmemonly nounwind }
77attributes #3 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "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" }
78attributes #4 = { nounwind }
79
80!llvm.dbg.cu = !{!0}
81!llvm.module.flags = !{!3, !4, !5, !6}
82!llvm.ident = !{!7}
83
84!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
85!1 = !DIFile(filename: "t.c", directory: "C:\5Csrc\5Cllvm-project\5Cbuild", checksumkind: CSK_MD5, checksum: "df0c1a43acd19a1255d45a3f2802cf9f")
86!2 = !{}
87!3 = !{i32 1, !"NumRegisterParameters", i32 0}
88!4 = !{i32 2, !"CodeView", i32 1}
89!5 = !{i32 2, !"Debug Info Version", i32 3}
90!6 = !{i32 1, !"wchar_size", i32 2}
91!7 = !{!"clang version 6.0.0 "}
92!8 = distinct !DISubprogram(name: "ssp", scope: !1, file: !1, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
93!9 = !DISubroutineType(types: !10)
94!10 = !{!11, !11}
95!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
96!12 = !{!13, !14}
97!13 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !1, line: 2, type: !11)
98!14 = !DILocalVariable(name: "arr", scope: !8, file: !1, line: 3, type: !15)
99!15 = !DICompositeType(tag: DW_TAG_array_type, baseType: !11, size: 128, elements: !16)
100!16 = !{!17}
101!17 = !DISubrange(count: 4)
102!18 = !DILocation(line: 2, column: 13, scope: !8)
103!19 = !DILocation(line: 3, column: 3, scope: !8)
104!20 = !DILocation(line: 3, column: 7, scope: !8)
105!21 = !DILocation(line: 3, column: 16, scope: !8)
106!22 = !{!23, !23, i64 0}
107!23 = !{!"int", !24, i64 0}
108!24 = !{!"omnipotent char", !25, i64 0}
109!25 = !{!"Simple C/C++ TBAA"}
110!26 = !DILocation(line: 4, column: 3, scope: !8)
111!27 = !DILocation(line: 6, column: 1, scope: !8)
112!28 = !DILocation(line: 5, column: 3, scope: !8)
113