1; RUN: llc -filetype=obj < %s > %t.obj 2; RUN: obj2yaml %t.obj | FileCheck %s --check-prefix=YAML 3; RUN: llc -filetype=asm < %s | FileCheck %s --check-prefix=ASM 4 5; C++ source to regenerate: 6; $ cat t.cpp 7; struct Foo { 8; Foo(int x, int y) : X(x), Y(y) {} 9; int method() { return X + Y; } 10; int X; 11; int Y; 12; }; 13; int main(int argc, char **argv) { 14; Foo F {argc, argc}; 15; return F.method(); 16; }; 17; $ clang-cc1 -triple i686-pc-windows-msvc19.11.25547 -emit-llvm -gcodeview \ 18; -debug-info-kind=limited -std=c++14 foo.cpp 19; 20 21 22; ModuleID = 'foo.cpp' 23source_filename = "foo.cpp" 24target datalayout = "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32-a:0:32-S32" 25target triple = "i686-pc-windows-msvc19.11.25547" 26 27%struct.Foo = type { i32, i32 } 28 29$"??0Foo@@QAE@HH@Z" = comdat any 30 31$"?method@Foo@@QAEHXZ" = comdat any 32 33; Function Attrs: mustprogress noinline norecurse nounwind optnone 34define dso_local noundef i32 @main(i32 noundef %argc, ptr noundef %argv) #0 !dbg !8 { 35entry: 36 %retval = alloca i32, align 4 37 %argv.addr = alloca ptr, align 4 38 %argc.addr = alloca i32, align 4 39 %F = alloca %struct.Foo, align 4 40 store i32 0, ptr %retval, align 4 41 store ptr %argv, ptr %argv.addr, align 4 42 call void @llvm.dbg.declare(metadata ptr %argv.addr, metadata !17, metadata !DIExpression()), !dbg !18 43 store i32 %argc, ptr %argc.addr, align 4 44 call void @llvm.dbg.declare(metadata ptr %argc.addr, metadata !19, metadata !DIExpression()), !dbg !20 45 call void @llvm.dbg.declare(metadata ptr %F, metadata !21, metadata !DIExpression()), !dbg !33 46 %0 = load i32, ptr %argc.addr, align 4, !dbg !34 47 %1 = load i32, ptr %argc.addr, align 4, !dbg !35 48 %call = call x86_thiscallcc noundef ptr @"??0Foo@@QAE@HH@Z"(ptr noundef nonnull align 4 dereferenceable(8) %F, i32 noundef %0, i32 noundef %1), !dbg !33 49 %call1 = call x86_thiscallcc noundef i32 @"?method@Foo@@QAEHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %F), !dbg !36 50 ret i32 %call1, !dbg !37 51} 52 53; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn 54declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 55 56; Function Attrs: noinline nounwind optnone 57define linkonce_odr dso_local x86_thiscallcc noundef ptr @"??0Foo@@QAE@HH@Z"(ptr noundef nonnull returned align 4 dereferenceable(8) %this, i32 noundef %x, i32 noundef %y) unnamed_addr #2 comdat align 2 !dbg !38 { 58entry: 59 %y.addr = alloca i32, align 4 60 %x.addr = alloca i32, align 4 61 %this.addr = alloca ptr, align 4 62 store i32 %y, ptr %y.addr, align 4 63 call void @llvm.dbg.declare(metadata ptr %y.addr, metadata !39, metadata !DIExpression()), !dbg !40 64 store i32 %x, ptr %x.addr, align 4 65 call void @llvm.dbg.declare(metadata ptr %x.addr, metadata !41, metadata !DIExpression()), !dbg !42 66 store ptr %this, ptr %this.addr, align 4 67 call void @llvm.dbg.declare(metadata ptr %this.addr, metadata !43, metadata !DIExpression()), !dbg !45 68 %this1 = load ptr, ptr %this.addr, align 4 69 %X = getelementptr inbounds %struct.Foo, ptr %this1, i32 0, i32 0, !dbg !46 70 %0 = load i32, ptr %x.addr, align 4, !dbg !47 71 store i32 %0, ptr %X, align 4, !dbg !46 72 %Y = getelementptr inbounds %struct.Foo, ptr %this1, i32 0, i32 1, !dbg !48 73 %1 = load i32, ptr %y.addr, align 4, !dbg !49 74 store i32 %1, ptr %Y, align 4, !dbg !48 75 ret ptr %this1, !dbg !50 76} 77 78; Function Attrs: mustprogress noinline nounwind optnone 79define linkonce_odr dso_local x86_thiscallcc noundef i32 @"?method@Foo@@QAEHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %this) #3 comdat align 2 !dbg !51 { 80entry: 81 %this.addr = alloca ptr, align 4 82 store ptr %this, ptr %this.addr, align 4 83 call void @llvm.dbg.declare(metadata ptr %this.addr, metadata !52, metadata !DIExpression()), !dbg !53 84 %this1 = load ptr, ptr %this.addr, align 4 85 %X = getelementptr inbounds %struct.Foo, ptr %this1, i32 0, i32 0, !dbg !54 86 %0 = load i32, ptr %X, align 4, !dbg !54 87 %Y = getelementptr inbounds %struct.Foo, ptr %this1, i32 0, i32 1, !dbg !55 88 %1 = load i32, ptr %Y, align 4, !dbg !55 89 %add = add nsw i32 %0, %1, !dbg !56 90 ret i32 %add, !dbg !57 91} 92 93attributes #0 = { mustprogress noinline norecurse nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+x87" } 94attributes #1 = { nocallback nofree nosync nounwind readnone speculatable willreturn } 95attributes #2 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+x87" } 96attributes #3 = { mustprogress noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+x87" } 97 98!llvm.dbg.cu = !{!0} 99!llvm.module.flags = !{!2, !3, !4, !5, !6} 100!llvm.ident = !{!7} 101 102!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 16.0.0 (https://github.com/llvm/llvm-project.git a784de783af5096e593c5e214c2c78215fe303f5)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) 103!1 = !DIFile(filename: "<stdin>", directory: "C:\\git\\llvm-project", checksumkind: CSK_MD5, checksum: "d54692241b2727e6ae75e9d429c51680") 104!2 = !{i32 1, !"NumRegisterParameters", i32 0} 105!3 = !{i32 2, !"CodeView", i32 1} 106!4 = !{i32 2, !"CodeViewGHash", i32 1} 107!5 = !{i32 2, !"Debug Info Version", i32 3} 108!6 = !{i32 1, !"wchar_size", i32 2} 109!7 = !{!"clang version 16.0.0 (https://github.com/llvm/llvm-project.git a784de783af5096e593c5e214c2c78215fe303f5)"} 110!8 = distinct !DISubprogram(name: "main", scope: !9, file: !9, line: 7, type: !10, scopeLine: 7, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !16) 111!9 = !DIFile(filename: "foo.cpp", directory: "C:\\git\\llvm-project", checksumkind: CSK_MD5, checksum: "d54692241b2727e6ae75e9d429c51680") 112!10 = !DISubroutineType(types: !11) 113!11 = !{!12, !12, !13} 114!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 115!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 32) 116!14 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !15, size: 32) 117!15 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) 118!16 = !{} 119!17 = !DILocalVariable(name: "argv", arg: 2, scope: !8, file: !9, line: 7, type: !13) 120!18 = !DILocation(line: 7, column: 27, scope: !8) 121!19 = !DILocalVariable(name: "argc", arg: 1, scope: !8, file: !9, line: 7, type: !12) 122!20 = !DILocation(line: 7, column: 14, scope: !8) 123!21 = !DILocalVariable(name: "F", scope: !8, file: !9, line: 8, type: !22) 124!22 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !9, line: 1, size: 64, flags: DIFlagTypePassByValue | DIFlagNonTrivial, elements: !23, identifier: ".?AUFoo@@") 125!23 = !{!24, !25, !26, !30} 126!24 = !DIDerivedType(tag: DW_TAG_member, name: "X", scope: !22, file: !9, line: 4, baseType: !12, size: 32) 127!25 = !DIDerivedType(tag: DW_TAG_member, name: "Y", scope: !22, file: !9, line: 5, baseType: !12, size: 32, offset: 32) 128!26 = !DISubprogram(name: "Foo", scope: !22, file: !9, line: 2, type: !27, scopeLine: 2, flags: DIFlagPrototyped, spFlags: 0) 129!27 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !28) 130!28 = !{null, !29, !12, !12} 131!29 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !22, size: 32, flags: DIFlagArtificial | DIFlagObjectPointer) 132!30 = !DISubprogram(name: "method", linkageName: "?method@Foo@@QAEHXZ", scope: !22, file: !9, line: 3, type: !31, scopeLine: 3, flags: DIFlagPrototyped, spFlags: 0) 133!31 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !32) 134!32 = !{!12, !29} 135!33 = !DILocation(line: 8, column: 7, scope: !8) 136!34 = !DILocation(line: 8, column: 10, scope: !8) 137!35 = !DILocation(line: 8, column: 16, scope: !8) 138!36 = !DILocation(line: 9, column: 12, scope: !8) 139!37 = !DILocation(line: 9, column: 3, scope: !8) 140!38 = distinct !DISubprogram(name: "Foo", linkageName: "??0Foo@@QAE@HH@Z", scope: !22, file: !9, line: 2, type: !27, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !26, retainedNodes: !16) 141!39 = !DILocalVariable(name: "y", arg: 3, scope: !38, file: !9, line: 2, type: !12) 142!40 = !DILocation(line: 2, column: 18, scope: !38) 143!41 = !DILocalVariable(name: "x", arg: 2, scope: !38, file: !9, line: 2, type: !12) 144!42 = !DILocation(line: 2, column: 11, scope: !38) 145!43 = !DILocalVariable(name: "this", arg: 1, scope: !38, type: !44, flags: DIFlagArtificial | DIFlagObjectPointer) 146!44 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !22, size: 32) 147!45 = !DILocation(line: 0, scope: !38) 148!46 = !DILocation(line: 2, column: 23, scope: !38) 149!47 = !DILocation(line: 2, column: 25, scope: !38) 150!48 = !DILocation(line: 2, column: 29, scope: !38) 151!49 = !DILocation(line: 2, column: 31, scope: !38) 152!50 = !DILocation(line: 2, column: 35, scope: !38) 153!51 = distinct !DISubprogram(name: "method", linkageName: "?method@Foo@@QAEHXZ", scope: !22, file: !9, line: 3, type: !31, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !30, retainedNodes: !16) 154!52 = !DILocalVariable(name: "this", arg: 1, scope: !51, type: !44, flags: DIFlagArtificial | DIFlagObjectPointer) 155!53 = !DILocation(line: 0, scope: !51) 156!54 = !DILocation(line: 3, column: 25, scope: !51) 157!55 = !DILocation(line: 3, column: 29, scope: !51) 158!56 = !DILocation(line: 3, column: 27, scope: !51) 159!57 = !DILocation(line: 3, column: 18, scope: !51) 160 161 162; YAML: --- !COFF 163; YAML: header: 164; YAML: Machine: IMAGE_FILE_MACHINE_I386 165; YAML: Characteristics: [ ] 166; YAML: sections: 167; YAML: - Name: '.debug$T' 168; YAML: Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] 169; YAML: Alignment: 4 170; YAML: Types: 171; YAML: - Kind: LF_POINTER 172; YAML: Pointer: 173; YAML: ReferentType: 1136 174; YAML: Attrs: 32778 175; YAML: - Kind: LF_ARGLIST 176; YAML: ArgList: 177; YAML: ArgIndices: [ 116, 4096 ] 178; YAML: - Kind: LF_PROCEDURE 179; YAML: Procedure: 180; YAML: ReturnType: 116 181; YAML: CallConv: NearC 182; YAML: Options: [ None ] 183; YAML: ParameterCount: 2 184; YAML: ArgumentList: 4097 185; YAML: - Kind: LF_FUNC_ID 186; YAML: FuncId: 187; YAML: ParentScope: 0 188; YAML: FunctionType: 4098 189; YAML: Name: main 190; YAML: - Kind: LF_STRUCTURE 191; YAML: Class: 192; YAML: MemberCount: 0 193; YAML: Options: [ None, ForwardReference, HasUniqueName ] 194; YAML: FieldList: 0 195; YAML: Name: Foo 196; YAML: UniqueName: '.?AUFoo@@' 197; YAML: DerivationList: 0 198; YAML: VTableShape: 0 199; YAML: Size: 0 200; YAML: - Kind: LF_POINTER 201; YAML: Pointer: 202; YAML: ReferentType: 4100 203; YAML: Attrs: 33802 204; YAML: - Kind: LF_ARGLIST 205; YAML: ArgList: 206; YAML: ArgIndices: [ 116, 116 ] 207; YAML: - Kind: LF_MFUNCTION 208; YAML: MemberFunction: 209; YAML: ReturnType: 3 210; YAML: ClassType: 4100 211; YAML: ThisType: 4101 212; YAML: CallConv: ThisCall 213; YAML: Options: [ None, Constructor ] 214; YAML: ParameterCount: 2 215; YAML: ArgumentList: 4102 216; YAML: ThisPointerAdjustment: 0 217; YAML: - Kind: LF_ARGLIST 218; YAML: ArgList: 219; YAML: ArgIndices: [ ] 220; YAML: - Kind: LF_MFUNCTION 221; YAML: MemberFunction: 222; YAML: ReturnType: 116 223; YAML: ClassType: 4100 224; YAML: ThisType: 4101 225; YAML: CallConv: ThisCall 226; YAML: Options: [ None ] 227; YAML: ParameterCount: 0 228; YAML: ArgumentList: 4104 229; YAML: ThisPointerAdjustment: 0 230; YAML: - Kind: LF_FIELDLIST 231; YAML: FieldList: 232; YAML: - Kind: LF_MEMBER 233; YAML: DataMember: 234; YAML: Attrs: 3 235; YAML: Type: 116 236; YAML: FieldOffset: 0 237; YAML: Name: X 238; YAML: - Kind: LF_MEMBER 239; YAML: DataMember: 240; YAML: Attrs: 3 241; YAML: Type: 116 242; YAML: FieldOffset: 4 243; YAML: Name: Y 244; YAML: - Kind: LF_ONEMETHOD 245; YAML: OneMethod: 246; YAML: Type: 4103 247; YAML: Attrs: 3 248; YAML: VFTableOffset: -1 249; YAML: Name: Foo 250; YAML: - Kind: LF_ONEMETHOD 251; YAML: OneMethod: 252; YAML: Type: 4105 253; YAML: Attrs: 3 254; YAML: VFTableOffset: -1 255; YAML: Name: method 256; YAML: - Kind: LF_STRUCTURE 257; YAML: Class: 258; YAML: MemberCount: 4 259; YAML: Options: [ None, HasConstructorOrDestructor, HasUniqueName ] 260; YAML: FieldList: 4106 261; YAML: Name: Foo 262; YAML: UniqueName: '.?AUFoo@@' 263; YAML: DerivationList: 0 264; YAML: VTableShape: 0 265; YAML: Size: 8 266; YAML: - Kind: LF_STRING_ID 267; YAML: StringId: 268; YAML: Id: 0 269; YAML: String: 'C:\git\llvm-project\foo.cpp' 270; YAML: - Kind: LF_UDT_SRC_LINE 271; YAML: UdtSourceLine: 272; YAML: UDT: 4107 273; YAML: SourceFile: 4108 274; YAML: LineNumber: 1 275; YAML: - Kind: LF_MFUNC_ID 276; YAML: MemberFuncId: 277; YAML: ClassType: 4100 278; YAML: FunctionType: 4103 279; YAML: Name: Foo 280; YAML: - Kind: LF_POINTER 281; YAML: Pointer: 282; YAML: ReferentType: 4100 283; YAML: Attrs: 32778 284; YAML: - Kind: LF_MFUNC_ID 285; YAML: MemberFuncId: 286; YAML: ClassType: 4100 287; YAML: FunctionType: 4105 288; YAML: Name: method 289; YAML: - Kind: LF_STRING_ID 290; YAML: StringId: 291; YAML: Id: 0 292; YAML: String: 'C:\git\llvm-project' 293; YAML: - Kind: LF_STRING_ID 294; YAML: StringId: 295; YAML: Id: 0 296; YAML: String: '<stdin>' 297; YAML: - Kind: LF_STRING_ID 298; YAML: StringId: 299; YAML: Id: 0 300; YAML: String: '' 301; YAML: - Kind: LF_BUILDINFO 302; YAML: BuildInfo: 303; YAML: ArgIndices: [ 4113, 4115, 4114, 4115, 4115 ] 304; YAML: - Name: '.debug$H' 305; YAML: Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] 306; YAML: Alignment: 4 307; YAML: GlobalHashes: 308; YAML: Version: 0 309; YAML: HashAlgorithm: 2 310; YAML: HashValues: 311; YAML: - 0FDF2CE06172DBE8 312; YAML: - B5E1C8329B9F4E7F 313; YAML: - 1EE1398011AA4BE1 314; YAML: - B682FB0B006CEC2E 315; YAML: - 8F2D2AE45F6E79E8 316; YAML: - 1747FDF05D25DDEE 317; YAML: - EAA738703837EBAE 318; YAML: - 07B9EF65EBA94121 319; YAML: - AFF81B6AE460D908 320; YAML: - 90DFD798AF84402C 321; YAML: - B9DDCF9F86BABE9E 322; YAML: - D1E2E5CAA3B96825 323; YAML: - 10994F943B4E46F3 324; YAML: - 4E2B6BC0E79F4271 325; YAML: - 72A4762DBB2AF2E4 326; YAML: - 1891CC40E9028AE7 327; YAML: - 1E6104ECC17E43DE 328; YAML: - 174CF4A3F5448049 329; YAML: - 5349856AF14E2246 330; YAML: - 55A48E0466FDCDA6 331; YAML: - EE6329A02D9F4959 332 333; ASM: .section .debug$H,"dr" 334; ASM-NEXT: .p2align 2 335; ASM-NEXT: .long 20171205 # Magic 336; ASM-NEXT: .short 0 # Section Version 337; ASM-NEXT: .short 2 # Hash Algorithm 338; ASM-NEXT: .byte 0x0f, 0xdf, 0x2c, 0xe0 # 0x1000 [0FDF2CE06172DBE8] 339; ASM-NEXT: .byte 0x61, 0x72, 0xdb, 0xe8 340; ASM-NEXT: .byte 0xb5, 0xe1, 0xc8, 0x32 # 0x1001 [B5E1C8329B9F4E7F] 341; ASM-NEXT: .byte 0x9b, 0x9f, 0x4e, 0x7f 342; ASM-NEXT: .byte 0x1e, 0xe1, 0x39, 0x80 # 0x1002 [1EE1398011AA4BE1]