1; RUN: llc < %s -filetype=obj -experimental-debug-variable-locations=true | llvm-readobj - --codeview | FileCheck %s 2; RUN: llc < %s -experimental-debug-variable-locations=true | llvm-mc -filetype=obj --triple=i686-windows | llvm-readobj - --codeview | FileCheck %s 3 4; C++ source to regenerate: 5; $ cat t.cpp 6; char multi_dim_arr[2][5][7]; 7; 8; struct incomplete_struct(*p_incomplete_struct_arr)[3]; 9; struct incomplete_struct { 10; int s1; 11; } incomplete_struct_arr[3]; 12; 13; void foo(int x) { 14; int dyn_size_arr[x]; 15; dyn_size_arr[0] = 0; 16; } 17; 18; typedef const volatile int T_INT; 19; T_INT typedef_arr[4] = {0}; 20; $ clang t.cpp -S -emit-llvm -g -gcodeview -o t.ll 21 22; CHECK: CodeViewTypes [ 23; CHECK: Section: .debug$T (6) 24; CHECK: Magic: 0x4 25; CHECK: ArgList (0x1000) { 26; CHECK: TypeLeafKind: LF_ARGLIST (0x1201) 27; CHECK: NumArgs: 1 28; CHECK: Arguments [ 29; CHECK: ArgType: int (0x74) 30; CHECK: ] 31; CHECK: } 32; CHECK: Procedure (0x1001) { 33; CHECK: TypeLeafKind: LF_PROCEDURE (0x1008) 34; CHECK: ReturnType: void (0x3) 35; CHECK: CallingConvention: NearC (0x0) 36; CHECK: FunctionOptions [ (0x0) 37; CHECK: ] 38; CHECK: NumParameters: 1 39; CHECK: ArgListType: (int) (0x1000) 40; CHECK: } 41; CHECK: FuncId (0x1002) { 42; CHECK: TypeLeafKind: LF_FUNC_ID (0x1601) 43; CHECK: ParentScope: 0x0 44; CHECK: FunctionType: void (int) (0x1001) 45; CHECK: Name: foo 46; CHECK: } 47; CHECK: Array (0x1003) { 48; CHECK: TypeLeafKind: LF_ARRAY (0x1503) 49; CHECK: ElementType: int (0x74) 50; CHECK: IndexType: unsigned long (0x22) 51; CHECK: SizeOf: 0 52; CHECK: Name: 53; CHECK: } 54; CHECK: Pointer (0x1004) { 55; CHECK: TypeLeafKind: LF_POINTER (0x1002) 56; CHECK: PointeeType: 0x1003 57; CHECK: PtrType: Near32 (0xA) 58; CHECK: PtrMode: LValueReference (0x1) 59; CHECK: IsFlat: 0 60; CHECK: IsConst: 0 61; CHECK: IsVolatile: 0 62; CHECK: IsUnaligned: 0 63; CHECK: SizeOf: 0 64; CHECK: } 65; CHECK: Array (0x1005) { 66; CHECK: TypeLeafKind: LF_ARRAY (0x1503) 67; CHECK: ElementType: char (0x70) 68; CHECK: IndexType: unsigned long (0x22) 69; CHECK: SizeOf: 7 70; CHECK: Name: 71; CHECK: } 72; CHECK: Array (0x1006) { 73; CHECK: TypeLeafKind: LF_ARRAY (0x1503) 74; CHECK: ElementType: 0x1005 75; CHECK: IndexType: unsigned long (0x22) 76; CHECK: SizeOf: 35 77; CHECK: Name: 78; CHECK: } 79; CHECK: Array (0x1007) { 80; CHECK: TypeLeafKind: LF_ARRAY (0x1503) 81; CHECK: ElementType: 0x1006 82; CHECK: IndexType: unsigned long (0x22) 83; CHECK: SizeOf: 70 84; CHECK: Name: 85; CHECK: } 86; CHECK: Struct (0x1008) { 87; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505) 88; CHECK: MemberCount: 0 89; CHECK: Properties [ (0x280) 90; CHECK: ForwardReference (0x80) 91; CHECK: HasUniqueName (0x200) 92; CHECK: ] 93; CHECK: FieldList: 0x0 94; CHECK: DerivedFrom: 0x0 95; CHECK: VShape: 0x0 96; CHECK: SizeOf: 0 97; CHECK: Name: incomplete_struct 98; CHECK: LinkageName: .?AUincomplete_struct@@ 99; CHECK: } 100; CHECK: Array (0x1009) { 101; CHECK: TypeLeafKind: LF_ARRAY (0x1503) 102; CHECK: ElementType: incomplete_struct (0x1008) 103; CHECK: IndexType: unsigned long (0x22) 104; CHECK: SizeOf: 12 105; CHECK: Name: 106; CHECK: } 107; CHECK: Pointer (0x100A) { 108; CHECK: TypeLeafKind: LF_POINTER (0x1002) 109; CHECK: PointeeType: 0x1009 110; CHECK: PtrType: Near32 (0xA) 111; CHECK: PtrMode: Pointer (0x0) 112; CHECK: IsFlat: 0 113; CHECK: IsConst: 0 114; CHECK: IsVolatile: 0 115; CHECK: IsUnaligned: 0 116; CHECK: SizeOf: 4 117; CHECK: } 118; CHECK: FieldList (0x100B) { 119; CHECK: TypeLeafKind: LF_FIELDLIST (0x1203) 120; CHECK: DataMember { 121; CHECK: TypeLeafKind: LF_MEMBER (0x150D) 122; CHECK: AccessSpecifier: Public (0x3) 123; CHECK: Type: int (0x74) 124; CHECK: FieldOffset: 0x0 125; CHECK: Name: s1 126; CHECK: } 127; CHECK: } 128; CHECK: Struct (0x100C) { 129; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505) 130; CHECK: MemberCount: 1 131; CHECK: Properties [ (0x200) 132; CHECK: HasUniqueName (0x200) 133; CHECK: ] 134; CHECK: FieldList: <field list> (0x100B) 135; CHECK: DerivedFrom: 0x0 136; CHECK: VShape: 0x0 137; CHECK: SizeOf: 4 138; CHECK: Name: incomplete_struct 139; CHECK: LinkageName: .?AUincomplete_struct@@ 140; CHECK: } 141; CHECK: StringId (0x100D) { 142; CHECK: TypeLeafKind: LF_STRING_ID (0x1605) 143; CHECK: Id: 0x0 144; CHECK: StringData: /t.cpp 145; CHECK: } 146; CHECK: UdtSourceLine (0x100E) { 147; CHECK: TypeLeafKind: LF_UDT_SRC_LINE (0x1606) 148; CHECK: UDT: incomplete_struct (0x100C) 149; CHECK: SourceFile: /t.cpp (0x100D) 150; CHECK: LineNumber: 4 151; CHECK: } 152; CHECK: Modifier (0x100F) { 153; CHECK: TypeLeafKind: LF_MODIFIER (0x1001) 154; CHECK: ModifiedType: int (0x74) 155; CHECK: Modifiers [ (0x3) 156; CHECK: Const (0x1) 157; CHECK: Volatile (0x2) 158; CHECK: ] 159; CHECK: } 160; CHECK: Array (0x1010) { 161; CHECK: TypeLeafKind: LF_ARRAY (0x1503) 162; CHECK: ElementType: const volatile int (0x100F) 163; CHECK: IndexType: unsigned long (0x22) 164; CHECK: SizeOf: 16 165; CHECK: Name: 166; CHECK: } 167; CHECK: ] 168 169source_filename = "test/DebugInfo/COFF/types-array-advanced.ll" 170target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" 171target triple = "i686-pc-windows-msvc18.0.31101" 172 173%struct.incomplete_struct = type { i32 } 174 175@"\01?multi_dim_arr@@3PAY146DA" = global [2 x [5 x [7 x i8]]] zeroinitializer, align 1, !dbg !0 176@"\01?p_incomplete_struct_arr@@3PAY02Uincomplete_struct@@A" = global ptr null, align 4, !dbg !6 177@"\01?incomplete_struct_arr@@3PAUincomplete_struct@@A" = global [3 x %struct.incomplete_struct] zeroinitializer, align 4, !dbg !16 178@"\01?typedef_arr@@3SDHD" = constant [4 x i32] zeroinitializer, align 4, !dbg !18 179 180; Function Attrs: nounwind 181define void @"\01?foo@@YAXH@Z"(i32 %x) #0 !dbg !35 { 182entry: 183 %x.addr = alloca i32, align 4 184 %saved_stack = alloca ptr, align 4 185 store i32 %x, ptr %x.addr, align 4 186 call void @llvm.dbg.declare(metadata ptr %x.addr, metadata !38, metadata !39), !dbg !40 187 %0 = load i32, ptr %x.addr, align 4, !dbg !41 188 %1 = call ptr @llvm.stacksave(), !dbg !42 189 store ptr %1, ptr %saved_stack, align 4, !dbg !42 190 %vla = alloca i32, i32 %0, align 4, !dbg !42 191 call void @llvm.dbg.declare(metadata ptr %vla, metadata !43, metadata !47), !dbg !48 192 store i32 0, ptr %vla, align 4, !dbg !50 193 %2 = load ptr, ptr %saved_stack, align 4, !dbg !51 194 call void @llvm.stackrestore(ptr %2), !dbg !51 195 ret void, !dbg !51 196} 197 198; Function Attrs: nounwind readnone 199declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 200 201; Function Attrs: nounwind 202declare ptr @llvm.stacksave() #0 203 204; Function Attrs: nounwind 205declare void @llvm.stackrestore(ptr) #0 206 207attributes #0 = { nounwind } 208attributes #1 = { nounwind readnone } 209 210!llvm.dbg.cu = !{!2} 211!llvm.module.flags = !{!32, !33} 212!llvm.ident = !{!34} 213 214!0 = distinct !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 215!1 = !DIGlobalVariable(name: "multi_dim_arr", linkageName: "\01?multi_dim_arr@@3PAY146DA", scope: !2, file: !3, line: 1, type: !26, isLocal: false, isDefinition: true) 216!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 3.9.0 (trunk 273874)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5) 217!3 = !DIFile(filename: "t.cpp", directory: "/") 218!4 = !{} 219!5 = !{!0, !6, !16, !18} 220!6 = distinct !DIGlobalVariableExpression(var: !7, expr: !DIExpression()) 221!7 = !DIGlobalVariable(name: "p_incomplete_struct_arr", linkageName: "\01?p_incomplete_struct_arr@@3PAY02Uincomplete_struct@@A", scope: !2, file: !3, line: 3, type: !8, isLocal: false, isDefinition: true) 222!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 32, align: 32) 223!9 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, elements: !14) 224!10 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "incomplete_struct", file: !3, line: 4, size: 32, align: 32, elements: !11, identifier: ".?AUincomplete_struct@@") 225!11 = !{!12} 226!12 = !DIDerivedType(tag: DW_TAG_member, name: "s1", scope: !10, file: !3, line: 5, baseType: !13, size: 32, align: 32) 227!13 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 228!14 = !{!15} 229!15 = !DISubrange(count: 3) 230!16 = distinct !DIGlobalVariableExpression(var: !17, expr: !DIExpression()) 231!17 = !DIGlobalVariable(name: "incomplete_struct_arr", linkageName: "\01?incomplete_struct_arr@@3PAUincomplete_struct@@A", scope: !2, file: !3, line: 6, type: !9, isLocal: false, isDefinition: true) 232!18 = distinct !DIGlobalVariableExpression(var: !19, expr: !DIExpression()) 233!19 = !DIGlobalVariable(name: "typedef_arr", linkageName: "\01?typedef_arr@@3SDHD", scope: !2, file: !3, line: 14, type: !20, isLocal: false, isDefinition: true) 234!20 = !DICompositeType(tag: DW_TAG_array_type, baseType: !21, size: 128, align: 32, elements: !24) 235!21 = !DIDerivedType(tag: DW_TAG_typedef, name: "T_INT", file: !3, line: 13, baseType: !22) 236!22 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !23) 237!23 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !13) 238!24 = !{!25} 239!25 = !DISubrange(count: 4) 240!26 = !DICompositeType(tag: DW_TAG_array_type, baseType: !27, size: 560, align: 8, elements: !28) 241!27 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char) 242!28 = !{!29, !30, !31} 243!29 = !DISubrange(count: 2) 244!30 = !DISubrange(count: 5) 245!31 = !DISubrange(count: 7) 246!32 = !{i32 2, !"CodeView", i32 1} 247!33 = !{i32 2, !"Debug Info Version", i32 3} 248!34 = !{!"clang version 3.9.0 (trunk 273874)"} 249!35 = distinct !DISubprogram(name: "foo", linkageName: "\01?foo@@YAXH@Z", scope: !3, file: !3, line: 8, type: !36, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !2, retainedNodes: !4) 250!36 = !DISubroutineType(types: !37) 251!37 = !{null, !13} 252!38 = !DILocalVariable(name: "x", arg: 1, scope: !35, file: !3, line: 8, type: !13) 253!39 = !DIExpression() 254!40 = !DILocation(line: 8, column: 14, scope: !35) 255!41 = !DILocation(line: 9, column: 21, scope: !35) 256!42 = !DILocation(line: 9, column: 4, scope: !35) 257!43 = !DILocalVariable(name: "dyn_size_arr", scope: !35, file: !3, line: 9, type: !44) 258!44 = !DICompositeType(tag: DW_TAG_array_type, baseType: !13, align: 32, elements: !45) 259!45 = !{!46} 260!46 = !DISubrange(count: -1) 261!47 = !DIExpression(DW_OP_deref) 262!48 = !DILocation(line: 9, column: 8, scope: !35) 263!49 = !DILocation(line: 10, column: 4, scope: !35) 264!50 = !DILocation(line: 10, column: 20, scope: !35) 265!51 = !DILocation(line: 11, column: 1, scope: !35) 266 267