1; RUN: llc -mtriple=x86_64-apple-darwin %s -o %t.o -filetype=obj -O0 2; RUN: llvm-dwarfdump -v %t.o | FileCheck %s 3; 4; Test that on x86_64, the 32-bit subregister esi is emitted as 5; subregister of the 64-bit rsi. 6; 7; rdar://problem/16015314 8; 9; CHECK: .debug_info contents: 10; CHECK: DW_TAG_variable 11; CHECK-NEXT: DW_AT_location [DW_FORM_data4] ( 12; CHECK-NEXT: [{{.*}}, {{.*}}): DW_OP_reg4 RSI) 13; CHECK-NEXT: DW_AT_name [DW_FORM_strp]{{.*}} "a" 14; 15; struct bar { 16; int a; 17; int b; 18; }; 19; 20; void doSomething() __attribute__ ((noinline)); 21; 22; void doSomething(struct bar *b) 23; { 24; int a = b->a; 25; printf("%d\n", a); // set breakpoint here 26; } 27; 28; int main() 29; { 30; struct bar myBar = { 3, 4 }; 31; doSomething(&myBar); 32; return 0; 33; } 34 35target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 36target triple = "x86_64-apple-macosx10.9.0" 37 38%struct.bar = type { i32, i32 } 39 40@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 41@main.myBar = private unnamed_addr constant %struct.bar { i32 3, i32 4 }, align 4 42 43; Function Attrs: noinline nounwind ssp uwtable 44define void @doSomething(%struct.bar* nocapture readonly %b) #0 !dbg !4 { 45entry: 46 tail call void @llvm.dbg.value(metadata %struct.bar* %b, metadata !15, metadata !DIExpression()), !dbg !25 47 %a1 = getelementptr inbounds %struct.bar, %struct.bar* %b, i64 0, i32 0, !dbg !26 48 %0 = load i32, i32* %a1, align 4, !dbg !26, !tbaa !27 49 tail call void @llvm.dbg.value(metadata i32 %0, metadata !16, metadata !DIExpression()), !dbg !26 50 %call = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %0) #4, !dbg !32 51 ret void, !dbg !33 52} 53 54; Function Attrs: nounwind readnone 55declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 56 57; Function Attrs: nounwind 58declare i32 @printf(i8* nocapture readonly, ...) #2 59 60; Function Attrs: nounwind ssp uwtable 61define i32 @main() #3 !dbg !17 { 62entry: 63 %myBar = alloca i64, align 8, !dbg !34 64 %tmpcast = bitcast i64* %myBar to %struct.bar*, !dbg !34 65 tail call void @llvm.dbg.declare(metadata %struct.bar* %tmpcast, metadata !21, metadata !DIExpression()), !dbg !34 66 store i64 17179869187, i64* %myBar, align 8, !dbg !34 67 call void @doSomething(%struct.bar* %tmpcast), !dbg !35 68 ret i32 0, !dbg !36 69} 70 71; Function Attrs: nounwind readnone 72declare void @llvm.dbg.value(metadata, metadata, metadata) #1 73 74attributes #0 = { noinline nounwind ssp uwtable } 75attributes #1 = { nounwind readnone } 76attributes #2 = { nounwind } 77attributes #3 = { nounwind ssp uwtable } 78attributes #4 = { nounwind } 79 80!llvm.dbg.cu = !{!0} 81!llvm.module.flags = !{!22, !23} 82!llvm.ident = !{!24} 83 84!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.5 ", isOptimized: true, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2) 85!1 = !DIFile(filename: "subregisters.c", directory: "") 86!2 = !{} 87!4 = distinct !DISubprogram(name: "doSomething", line: 10, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 11, file: !1, scope: !5, type: !6, retainedNodes: !14) 88!5 = !DIFile(filename: "subregisters.c", directory: "") 89!6 = !DISubroutineType(types: !7) 90!7 = !{null, !8} 91!8 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !9) 92!9 = !DICompositeType(tag: DW_TAG_structure_type, name: "bar", line: 3, size: 64, align: 32, file: !1, elements: !10) 93!10 = !{!11, !13} 94!11 = !DIDerivedType(tag: DW_TAG_member, name: "a", line: 4, size: 32, align: 32, file: !1, scope: !9, baseType: !12) 95!12 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 96!13 = !DIDerivedType(tag: DW_TAG_member, name: "b", line: 5, size: 32, align: 32, offset: 32, file: !1, scope: !9, baseType: !12) 97!14 = !{!15, !16} 98!15 = !DILocalVariable(name: "b", line: 10, arg: 1, scope: !4, file: !5, type: !8) 99!16 = !DILocalVariable(name: "a", line: 12, scope: !4, file: !5, type: !12) 100!17 = distinct !DISubprogram(name: "main", line: 16, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: true, unit: !0, scopeLine: 17, file: !1, scope: !5, type: !18, retainedNodes: !20) 101!18 = !DISubroutineType(types: !19) 102!19 = !{!12} 103!20 = !{!21} 104!21 = !DILocalVariable(name: "myBar", line: 18, scope: !17, file: !5, type: !9) 105!22 = !{i32 2, !"Dwarf Version", i32 2} 106!23 = !{i32 1, !"Debug Info Version", i32 3} 107!24 = !{!"clang version 3.5 "} 108!25 = !DILocation(line: 10, scope: !4) 109!26 = !DILocation(line: 12, scope: !4) 110!27 = !{!28, !29, i64 0} 111!28 = !{!"bar", !29, i64 0, !29, i64 4} 112!29 = !{!"int", !30, i64 0} 113!30 = !{!"omnipotent char", !31, i64 0} 114!31 = !{!"Simple C/C++ TBAA"} 115!32 = !DILocation(line: 13, scope: !4) 116!33 = !DILocation(line: 14, scope: !4) 117!34 = !DILocation(line: 18, scope: !17) 118!35 = !DILocation(line: 19, scope: !17) 119!36 = !DILocation(line: 20, scope: !17) 120