Revert r354244 "[DAGCombiner] Eliminate dead stores to stack."
[llvm-complete.git] / test / DebugInfo / COFF / lambda.ll
blob904bd801f8d1ea53c5e1f22c9c62feb9b7589913
1 ; RUN: llc < %s -filetype=obj | llvm-readobj - -codeview | FileCheck %s
3 ; Verify lambda routines are emitted properly in CodeView.
5 ; The original source code:
6 ; -----------------------------------------------------------------------------
7 ; int main(int argc, char* argv[], char* arge[]) {
8 ;   auto Lambda = [argc](int count) -> int { return argc == count ? 1 : 0; };
9 ;   return Lambda(0);
10 ; }
11 ; -----------------------------------------------------------------------------
13 ; To regenerate the IR below compile the source code:
14 ;   $ clang lambda.cxx -S -emit-llvm -g -gcodeview
16 ; CHECK:      FieldList ([[FIELDLIST_ID:0x[0-9A-F]+]]) {
17 ; CHECK-NEXT:   TypeLeafKind: LF_FIELDLIST ({{.*}})
18 ; CHECK-NEXT:   DataMember {
19 ; CHECK-NEXT:     TypeLeafKind: LF_MEMBER ({{.*}})
20 ; CHECK-NEXT:     AccessSpecifier: Private ({{.*}})
21 ; CHECK-NEXT:     Type: int ({{.*}})
22 ; CHECK-NEXT:     FieldOffset: {{.*}}
23 ; CHECK-NEXT:     Name: argc
24 ; CHECK-NEXT:   }
25 ; CHECK-NEXT:   OneMethod {
26 ; CHECK-NEXT:     TypeLeafKind: LF_ONEMETHOD (0x1511)
27 ; CHECK-NEXT:     AccessSpecifier: Public (0x3)
28 ; CHECK-NEXT:     Type: int main::<unnamed-tag>::(int) ({{.*}})
29 ; CHECK-NEXT:     Name: operator()
30 ; CHECK-NEXT:   }
31 ; CHECK-NEXT: }
32 ; CHECK-NEXT: Class ([[CLASS_ID:0x[0-9A-F]+]]) {
33 ; CHECK-NEXT:   TypeLeafKind: LF_CLASS ({{.*}})
34 ; CHECK-NEXT:   MemberCount: {{.*}}
35 ; CHECK-NEXT:   Properties [ ({{.*}})
36 ; CHECK-NEXT:     HasUniqueName ({{.*}})
37 ; CHECK-NEXT:     Scoped ({{.*}})
38 ; CHECK-NEXT:   ]
39 ; CHECK-NEXT:   FieldList: <field list> ([[FIELDLIST_ID]])
40 ; CHECK-NEXT:   DerivedFrom: {{.*}}
41 ; CHECK-NEXT:   VShape: {{.*}}
42 ; CHECK-NEXT:   SizeOf: {{.*}}
43 ; CHECK-NEXT:   Name: main::<unnamed-tag>
44 ; CHECK-NEXT:   LinkageName: {{.*lambda.*}}
45 ; CHECK-NEXT: }
46 ;             LocalSym {
47 ;               Kind: S_LOCAL ({{.*}})
48 ; CHECK:        Type: main::<unnamed-tag> ([[CLASS_ID]])
49 ;               Flags [ (0x0)
50 ;               ]
51 ; CHECK:        VarName: Lambda
52 ;             }
54 ; ModuleID = 'lambda.cxx'
55 source_filename = "lambda.cxx"
56 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
57 target triple = "i686-pc-windows-msvc19.0.24210"
59 %class.anon = type { i32 }
61 ; Function Attrs: noinline norecurse optnone
62 define dso_local i32 @main(i32 %argc, i8** %argv, i8** %arge) #0 !dbg !8 {
63 entry:
64   %retval = alloca i32, align 4
65   %arge.addr = alloca i8**, align 4
66   %argv.addr = alloca i8**, align 4
67   %argc.addr = alloca i32, align 4
68   %Lambda = alloca %class.anon, align 4
69   store i32 0, i32* %retval, align 4
70   store i8** %arge, i8*** %arge.addr, align 4
71   call void @llvm.dbg.declare(metadata i8*** %arge.addr, metadata !15, metadata !DIExpression()), !dbg !16
72   store i8** %argv, i8*** %argv.addr, align 4
73   call void @llvm.dbg.declare(metadata i8*** %argv.addr, metadata !17, metadata !DIExpression()), !dbg !16
74   store i32 %argc, i32* %argc.addr, align 4
75   call void @llvm.dbg.declare(metadata i32* %argc.addr, metadata !18, metadata !DIExpression()), !dbg !16
76   call void @llvm.dbg.declare(metadata %class.anon* %Lambda, metadata !19, metadata !DIExpression()), !dbg !28
77   %0 = getelementptr inbounds %class.anon, %class.anon* %Lambda, i32 0, i32 0, !dbg !28
78   %1 = load i32, i32* %argc.addr, align 4, !dbg !28
79   store i32 %1, i32* %0, align 4, !dbg !28
80   %call = call x86_thiscallcc i32 @"??R<lambda_0>@?0??main@@9@QBE@H@Z"(%class.anon* %Lambda, i32 0), !dbg !29
81   ret i32 %call, !dbg !29
84 ; Function Attrs: nounwind readnone speculatable
85 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
87 ; Function Attrs: noinline nounwind optnone
88 define internal x86_thiscallcc i32 @"??R<lambda_0>@?0??main@@9@QBE@H@Z"(%class.anon* %this, i32 %count) #2 align 2 !dbg !30 {
89 entry:
90   %count.addr = alloca i32, align 4
91   %this.addr = alloca %class.anon*, align 4
92   store i32 %count, i32* %count.addr, align 4
93   call void @llvm.dbg.declare(metadata i32* %count.addr, metadata !31, metadata !DIExpression()), !dbg !32
94   store %class.anon* %this, %class.anon** %this.addr, align 4
95   call void @llvm.dbg.declare(metadata %class.anon** %this.addr, metadata !33, metadata !DIExpression()), !dbg !35
96   %this1 = load %class.anon*, %class.anon** %this.addr, align 4
97   %0 = getelementptr inbounds %class.anon, %class.anon* %this1, i32 0, i32 0, !dbg !32
98   %1 = load i32, i32* %0, align 4, !dbg !32
99   %2 = load i32, i32* %count.addr, align 4, !dbg !32
100   %cmp = icmp eq i32 %1, %2, !dbg !32
101   %3 = zext i1 %cmp to i64, !dbg !32
102   %cond = select i1 %cmp, i32 1, i32 0, !dbg !32
103   ret i32 %cond, !dbg !32
106 attributes #0 = { noinline norecurse optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "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" }
107 attributes #1 = { nounwind readnone speculatable }
108 attributes #2 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "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" }
110 !llvm.dbg.cu = !{!0}
111 !llvm.module.flags = !{!3, !4, !5, !6}
112 !llvm.ident = !{!7}
114 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 7.0.0 (trunk)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
115 !1 = !DIFile(filename: "lambda.cxx", directory: "C:\5Cpath\5Cto", checksumkind: CSK_MD5, checksum: "8d860c432e3763effaf1658460a496c0")
116 !2 = !{}
117 !3 = !{i32 1, !"NumRegisterParameters", i32 0}
118 !4 = !{i32 2, !"CodeView", i32 1}
119 !5 = !{i32 2, !"Debug Info Version", i32 3}
120 !6 = !{i32 1, !"wchar_size", i32 2}
121 !7 = !{!"clang version 7.0.0 (trunk)"}
122 !8 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 1, type: !9, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
123 !9 = !DISubroutineType(types: !10)
124 !10 = !{!11, !11, !12, !12}
125 !11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
126 !12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 32)
127 !13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 32)
128 !14 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
129 !15 = !DILocalVariable(name: "arge", arg: 3, scope: !8, file: !1, line: 1, type: !12)
130 !16 = !DILocation(line: 1, scope: !8)
131 !17 = !DILocalVariable(name: "argv", arg: 2, scope: !8, file: !1, line: 1, type: !12)
132 !18 = !DILocalVariable(name: "argc", arg: 1, scope: !8, file: !1, line: 1, type: !11)
133 !19 = !DILocalVariable(name: "Lambda", scope: !8, file: !1, line: 2, type: !20)
134 !20 = distinct !DICompositeType(tag: DW_TAG_class_type, scope: !8, file: !1, line: 2, size: 32, flags: DIFlagTypePassByValue, elements: !21, identifier: "??R<lambda_0>@?0??main@@9@QBE@H@Z")
135 !21 = !{!22, !23}
136 !22 = !DIDerivedType(tag: DW_TAG_member, name: "argc", scope: !20, file: !1, line: 2, baseType: !11, size: 32)
137 !23 = !DISubprogram(name: "operator()", scope: !20, file: !1, line: 2, type: !24, isLocal: false, isDefinition: false, scopeLine: 2, flags: DIFlagPublic | DIFlagPrototyped, isOptimized: false)
138 !24 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !25)
139 !25 = !{!11, !26, !11}
140 !26 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !27, size: 32, flags: DIFlagArtificial | DIFlagObjectPointer)
141 !27 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !20)
142 !28 = !DILocation(line: 2, scope: !8)
143 !29 = !DILocation(line: 3, scope: !8)
144 !30 = distinct !DISubprogram(name: "operator()", linkageName: "??R<lambda_0>@?0??main@@9@QBE@H@Z", scope: !20, file: !1, line: 2, type: !24, isLocal: true, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, declaration: !23, retainedNodes: !2)
145 !31 = !DILocalVariable(name: "count", arg: 2, scope: !30, file: !1, line: 2, type: !11)
146 !32 = !DILocation(line: 2, scope: !30)
147 !33 = !DILocalVariable(name: "this", arg: 1, scope: !30, type: !34, flags: DIFlagArtificial | DIFlagObjectPointer)
148 !34 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !27, size: 32)
149 !35 = !DILocation(line: 0, scope: !30)