1; RUN: llc < %s -filetype=obj -o - | llvm-readobj - --codeview | FileCheck %s
2; RUN: llc < %s -o - | llvm-mc -filetype=obj --triple=i386-windows | llvm-readobj - --codeview | FileCheck %s
3
4; C++ source to regenerate:
5; $ cat t.cpp
6; struct A {
7;   void thiscallcc();
8; };
9; void A::thiscallcc() {}
10; void cdeclcc() {}
11; void __fastcall fastcallcc() {}
12; void __stdcall stdcallcc() {}
13; void __vectorcall vectorcallcc() {}
14; $ clang -g -gcodeview t.cpp -emit-llvm -S -o t.ll -O1
15
16; CHECK: CodeViewTypes [
17; CHECK:   Section: .debug$T (5)
18; CHECK:   Magic: 0x4
19; CHECK:   Struct (0x1000) {
20; CHECK:     TypeLeafKind: LF_STRUCTURE (0x1505)
21; CHECK:     MemberCount: 0
22; CHECK:     Properties [ (0x80)
23; CHECK:       ForwardReference (0x80)
24; CHECK:     ]
25; CHECK:     FieldList: 0x0
26; CHECK:     DerivedFrom: 0x0
27; CHECK:     VShape: 0x0
28; CHECK:     SizeOf: 0
29; CHECK:     Name: A
30; CHECK:   }
31; CHECK:   Pointer (0x1001) {
32; CHECK:     TypeLeafKind: LF_POINTER (0x1002)
33; CHECK:     PointeeType: A (0x1000)
34; CHECK:     PtrType: Near32 (0xA)
35; CHECK:     PtrMode: Pointer (0x0)
36; CHECK:     IsFlat: 0
37; CHECK:     IsConst: 1
38; CHECK:     IsVolatile: 0
39; CHECK:     IsUnaligned: 0
40; CHECK:     SizeOf: 4
41; CHECK:   }
42; CHECK:   ArgList (0x1002) {
43; CHECK:     TypeLeafKind: LF_ARGLIST (0x1201)
44; CHECK:     NumArgs: 0
45; CHECK:     Arguments [
46; CHECK:     ]
47; CHECK:   }
48; CHECK:   MemberFunction (0x1003) {
49; CHECK:     TypeLeafKind: LF_MFUNCTION (0x1009)
50; CHECK:     ReturnType: void (0x3)
51; CHECK:     ClassType: A (0x1000)
52; CHECK:     ThisType: A* const (0x1001)
53; CHECK:     CallingConvention: ThisCall (0xB)
54; CHECK:     FunctionOptions [ (0x0)
55; CHECK:     ]
56; CHECK:     NumParameters: 0
57; CHECK:     ArgListType: () (0x1002)
58; CHECK:     ThisAdjustment: 0
59; CHECK:   }
60; CHECK:   FieldList (0x1004) {
61; CHECK:     TypeLeafKind: LF_FIELDLIST (0x1203)
62; CHECK:     OneMethod {
63; CHECK:       AccessSpecifier: Public (0x3)
64; CHECK:       Type: void A::() (0x1003)
65; CHECK:       Name: A::thiscallcc
66; CHECK:     }
67; CHECK:   }
68; CHECK:   Struct (0x1005) {
69; CHECK:     TypeLeafKind: LF_STRUCTURE (0x1505)
70; CHECK:     MemberCount: 1
71; CHECK:     Properties [ (0x0)
72; CHECK:     ]
73; CHECK:     FieldList: <field list> (0x1004)
74; CHECK:     DerivedFrom: 0x0
75; CHECK:     VShape: 0x0
76; CHECK:     SizeOf: 1
77; CHECK:     Name: A
78; CHECK:   }
79; CHECK:   StringId (0x1006) {
80; CHECK:     TypeLeafKind: LF_STRING_ID (0x1605)
81; CHECK:     Id: 0x0
82; CHECK:     StringData: D:\src\llvm\build\t.cpp
83; CHECK:   }
84; CHECK:   UdtSourceLine (0x1007) {
85; CHECK:     TypeLeafKind: LF_UDT_SRC_LINE (0x1606)
86; CHECK:     UDT: A (0x1005)
87; CHECK:     SourceFile: D:\src\llvm\build\t.cpp (0x1006)
88; CHECK:     LineNumber: 1
89; CHECK:   }
90; CHECK:   MemberFuncId (0x1008) {
91; CHECK:     TypeLeafKind: LF_MFUNC_ID (0x1602)
92; CHECK:     ClassType: A (0x1000)
93; CHECK:     FunctionType: void A::() (0x1003)
94; CHECK:     Name: A::thiscallcc
95; CHECK:   }
96; CHECK:   Pointer (0x1009) {
97; CHECK:     TypeLeafKind: LF_POINTER (0x1002)
98; CHECK:     PointeeType: A (0x1000)
99; CHECK:     PtrType: Near32 (0xA)
100; CHECK:     PtrMode: Pointer (0x0)
101; CHECK:     IsFlat: 0
102; CHECK:     IsConst: 0
103; CHECK:     IsVolatile: 0
104; CHECK:     IsUnaligned: 0
105; CHECK:     IsRestrict: 0
106; CHECK:     SizeOf: 4
107; CHECK:   }
108; CHECK:   Procedure (0x100A) {
109; CHECK:     TypeLeafKind: LF_PROCEDURE (0x1008)
110; CHECK:     ReturnType: void (0x3)
111; CHECK:     CallingConvention: NearC (0x0)
112; CHECK:     FunctionOptions [ (0x0)
113; CHECK:     ]
114; CHECK:     NumParameters: 0
115; CHECK:     ArgListType: () (0x1002)
116; CHECK:   }
117; CHECK:   FuncId (0x100B) {
118; CHECK:     TypeLeafKind: LF_FUNC_ID (0x1601)
119; CHECK:     ParentScope: 0x0
120; CHECK:     FunctionType: void () (0x100A)
121; CHECK:     Name: cdeclcc
122; CHECK:   }
123; CHECK:   Procedure (0x100C) {
124; CHECK:     TypeLeafKind: LF_PROCEDURE (0x1008)
125; CHECK:     ReturnType: void (0x3)
126; CHECK:     CallingConvention: NearFast (0x4)
127; CHECK:     FunctionOptions [ (0x0)
128; CHECK:     ]
129; CHECK:     NumParameters: 0
130; CHECK:     ArgListType: () (0x1002)
131; CHECK:   }
132; CHECK:   FuncId (0x100D) {
133; CHECK:     TypeLeafKind: LF_FUNC_ID (0x1601)
134; CHECK:     ParentScope: 0x0
135; CHECK:     FunctionType: void () (0x100C)
136; CHECK:     Name: fastcallcc
137; CHECK:   }
138; CHECK:   Procedure (0x100E) {
139; CHECK:     TypeLeafKind: LF_PROCEDURE (0x1008)
140; CHECK:     ReturnType: void (0x3)
141; CHECK:     CallingConvention: NearStdCall (0x7)
142; CHECK:     FunctionOptions [ (0x0)
143; CHECK:     ]
144; CHECK:     NumParameters: 0
145; CHECK:     ArgListType: () (0x1002)
146; CHECK:   }
147; CHECK:   FuncId (0x100F) {
148; CHECK:     TypeLeafKind: LF_FUNC_ID (0x1601)
149; CHECK:     ParentScope: 0x0
150; CHECK:     FunctionType: void () (0x100E)
151; CHECK:     Name: stdcallcc
152; CHECK:   }
153; CHECK:   Procedure (0x1010) {
154; CHECK:     TypeLeafKind: LF_PROCEDURE (0x1008)
155; CHECK:     ReturnType: void (0x3)
156; CHECK:     CallingConvention: NearVector (0x18)
157; CHECK:     FunctionOptions [ (0x0)
158; CHECK:     ]
159; CHECK:     NumParameters: 0
160; CHECK:     ArgListType: () (0x1002)
161; CHECK:   }
162; CHECK:   FuncId (0x1011) {
163; CHECK:     TypeLeafKind: LF_FUNC_ID (0x1601)
164; CHECK:     ParentScope: 0x0
165; CHECK:     FunctionType: void () (0x1010)
166; CHECK:     Name: vectorcallcc
167; CHECK:   }
168; CHECK: ]
169
170; ModuleID = 't.cpp'
171source_filename = "t.cpp"
172target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
173target triple = "i386-pc-windows-msvc19.0.23918"
174
175%struct.A = type { i8 }
176
177; Function Attrs: nounwind readnone
178define x86_thiscallcc void @"\01?thiscallcc@A@@QAEXXZ"(%struct.A* nocapture %this) #0 align 2 !dbg !6 {
179entry:
180  tail call void @llvm.dbg.value(metadata %struct.A* %this, metadata !14, metadata !16), !dbg !17
181  ret void, !dbg !18
182}
183
184; Function Attrs: norecurse nounwind readnone
185define void @"\01?cdeclcc@@YAXXZ"() #1 !dbg !19 {
186entry:
187  ret void, !dbg !22
188}
189
190; Function Attrs: norecurse nounwind readnone
191define x86_fastcallcc void @"\01?fastcallcc@@YIXXZ"() #1 !dbg !23 {
192entry:
193  ret void, !dbg !24
194}
195
196; Function Attrs: norecurse nounwind readnone
197define x86_stdcallcc void @"\01?stdcallcc@@YGXXZ"() #1 !dbg !25 {
198entry:
199  ret void, !dbg !26
200}
201
202; Function Attrs: norecurse nounwind readnone
203define x86_vectorcallcc void @"\01?vectorcallcc@@YQXXZ"() #1 !dbg !27 {
204entry:
205  ret void, !dbg !28
206}
207
208; Function Attrs: nounwind readnone
209declare void @llvm.dbg.value(metadata, metadata, metadata) #2
210
211attributes #0 = { nounwind readnone "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" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
212attributes #1 = { norecurse nounwind readnone "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" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
213attributes #2 = { nounwind readnone }
214
215!llvm.dbg.cu = !{!0}
216!llvm.module.flags = !{!3, !4}
217!llvm.ident = !{!5}
218
219!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 (trunk 272067)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
220!1 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild")
221!2 = !{}
222!3 = !{i32 2, !"CodeView", i32 1}
223!4 = !{i32 2, !"Debug Info Version", i32 3}
224!5 = !{!"clang version 3.9.0 (trunk 272067)"}
225!6 = distinct !DISubprogram(name: "A::thiscallcc", linkageName: "\01?thiscallcc@A@@QAEXXZ", scope: !7, file: !1, line: 4, type: !10, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: true, unit: !0, declaration: !9, retainedNodes: !13)
226!7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !1, line: 1, size: 8, align: 8, elements: !8)
227!8 = !{!9}
228!9 = !DISubprogram(name: "A::thiscallcc", linkageName: "\01?thiscallcc@A@@QAEXXZ", scope: !7, file: !1, line: 2, type: !10, isLocal: false, isDefinition: false, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true)
229!10 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !11)
230!11 = !{null, !12}
231!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 32, align: 32, flags: DIFlagArtificial | DIFlagObjectPointer)
232!13 = !{!14}
233!14 = !DILocalVariable(name: "this", arg: 1, scope: !6, type: !15, flags: DIFlagArtificial | DIFlagObjectPointer)
234!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 32, align: 32)
235!16 = !DIExpression()
236!17 = !DILocation(line: 0, scope: !6)
237!18 = !DILocation(line: 4, column: 23, scope: !6)
238!19 = distinct !DISubprogram(name: "cdeclcc", linkageName: "\01?cdeclcc@@YAXXZ", scope: !1, file: !1, line: 5, type: !20, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2)
239!21 = !{null}
240!22 = !DILocation(line: 5, column: 17, scope: !19)
241!23 = distinct !DISubprogram(name: "fastcallcc", linkageName: "\01?fastcallcc@@YIXXZ", scope: !1, file: !1, line: 6, type: !29, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2)
242!24 = !DILocation(line: 6, column: 31, scope: !23)
243!25 = distinct !DISubprogram(name: "stdcallcc", linkageName: "\01?stdcallcc@@YGXXZ", scope: !1, file: !1, line: 7, type: !30, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2)
244!26 = !DILocation(line: 7, column: 29, scope: !25)
245!27 = distinct !DISubprogram(name: "vectorcallcc", linkageName: "\01?vectorcallcc@@YQXXZ", scope: !1, file: !1, line: 8, type: !31, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2)
246!28 = !DILocation(line: 8, column: 35, scope: !27)
247
248!20 = !DISubroutineType(cc: DW_CC_normal, types: !21)
249!29 = !DISubroutineType(cc: DW_CC_BORLAND_msfastcall, types: !21)
250!30 = !DISubroutineType(cc: DW_CC_BORLAND_stdcall, types: !21)
251!31 = !DISubroutineType(cc: DW_CC_LLVM_vectorcall, types: !21)
252