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