1*9880d681SAndroid Build Coastguard Worker; RUN: llc -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker; 3*9880d681SAndroid Build Coastguard Worker; PR22296: In this testcase the DBG_VALUE describing "p5" becomes unavailable 4*9880d681SAndroid Build Coastguard Worker; because the register its address is in is clobbered and we (currently) aren't 5*9880d681SAndroid Build Coastguard Worker; smart enough to realize that the value is rematerialized immediately after the 6*9880d681SAndroid Build Coastguard Worker; DBG_VALUE and/or is actually a stack slot. 7*9880d681SAndroid Build Coastguard Worker; 8*9880d681SAndroid Build Coastguard Worker; Test that we handle this situation gracefully by omitting the DW_AT_location 9*9880d681SAndroid Build Coastguard Worker; and not asserting. 10*9880d681SAndroid Build Coastguard Worker; Note that this check may XPASS in the future if DbgValueHistoryCalculator 11*9880d681SAndroid Build Coastguard Worker; becoms smarter. That would be fine, too. 12*9880d681SAndroid Build Coastguard Worker; 13*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_subprogram 14*9880d681SAndroid Build Coastguard Worker; CHECK: linkage_name{{.*}}_Z2f21A 15*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_formal_parameter 16*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: DW_AT_location 17*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: DW_AT_name {{.*}}"p5" 18*9880d681SAndroid Build Coastguard Worker; 19*9880d681SAndroid Build Coastguard Worker; // Compile at -O1 20*9880d681SAndroid Build Coastguard Worker; struct A { 21*9880d681SAndroid Build Coastguard Worker; int *m1; 22*9880d681SAndroid Build Coastguard Worker; int m2; 23*9880d681SAndroid Build Coastguard Worker; }; 24*9880d681SAndroid Build Coastguard Worker; 25*9880d681SAndroid Build Coastguard Worker; void f1(int *p1, int p2); 26*9880d681SAndroid Build Coastguard Worker; void __attribute__((always_inline)) f2(A p5) { f1(p5.m1, p5.m2); } 27*9880d681SAndroid Build Coastguard Worker; 28*9880d681SAndroid Build Coastguard Worker; void func(void*); 29*9880d681SAndroid Build Coastguard Worker; void func(const int &, const int&); 30*9880d681SAndroid Build Coastguard Worker; int cond(); 31*9880d681SAndroid Build Coastguard Worker; void f() { 32*9880d681SAndroid Build Coastguard Worker; while (cond()) { 33*9880d681SAndroid Build Coastguard Worker; int x; 34*9880d681SAndroid Build Coastguard Worker; func(x, 0); 35*9880d681SAndroid Build Coastguard Worker; while (cond()) { 36*9880d681SAndroid Build Coastguard Worker; char y; 37*9880d681SAndroid Build Coastguard Worker; func(&y); 38*9880d681SAndroid Build Coastguard Worker; char j; 39*9880d681SAndroid Build Coastguard Worker; func(&j); 40*9880d681SAndroid Build Coastguard Worker; char I; 41*9880d681SAndroid Build Coastguard Worker; func(&I); 42*9880d681SAndroid Build Coastguard Worker; func(0, 0); 43*9880d681SAndroid Build Coastguard Worker; A g; 44*9880d681SAndroid Build Coastguard Worker; g.m1 = &x; 45*9880d681SAndroid Build Coastguard Worker; f2(g); 46*9880d681SAndroid Build Coastguard Worker; } 47*9880d681SAndroid Build Coastguard Worker; } 48*9880d681SAndroid Build Coastguard Worker; } 49*9880d681SAndroid Build Coastguard Worker; ModuleID = 'test.cpp' 50*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 51*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-apple-macosx10.10.0" 52*9880d681SAndroid Build Coastguard Worker 53*9880d681SAndroid Build Coastguard Worker%struct.A = type { i32*, i32 } 54*9880d681SAndroid Build Coastguard Worker 55*9880d681SAndroid Build Coastguard Worker; Function Attrs: alwaysinline ssp uwtable 56*9880d681SAndroid Build Coastguard Workerdefine void @_Z2f21A(i32* %p5.coerce0, i32 %p5.coerce1) #0 !dbg !11 { 57*9880d681SAndroid Build Coastguard Workerentry: 58*9880d681SAndroid Build Coastguard Worker tail call void @llvm.dbg.value(metadata i32* %p5.coerce0, i64 0, metadata !16, metadata !33), !dbg !34 59*9880d681SAndroid Build Coastguard Worker tail call void @llvm.dbg.value(metadata i32 %p5.coerce1, i64 0, metadata !16, metadata !35), !dbg !34 60*9880d681SAndroid Build Coastguard Worker tail call void @llvm.dbg.declare(metadata %struct.A* undef, metadata !16, metadata !36), !dbg !34 61*9880d681SAndroid Build Coastguard Worker tail call void @_Z2f1Pii(i32* %p5.coerce0, i32 %p5.coerce1), !dbg !37 62*9880d681SAndroid Build Coastguard Worker ret void, !dbg !38 63*9880d681SAndroid Build Coastguard Worker} 64*9880d681SAndroid Build Coastguard Worker 65*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind readnone 66*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.dbg.declare(metadata, metadata, metadata) #1 67*9880d681SAndroid Build Coastguard Worker 68*9880d681SAndroid Build Coastguard Workerdeclare void @_Z2f1Pii(i32*, i32) #2 69*9880d681SAndroid Build Coastguard Worker 70*9880d681SAndroid Build Coastguard Worker; Function Attrs: ssp uwtable 71*9880d681SAndroid Build Coastguard Workerdefine void @_Z1fv() #3 !dbg !17 { 72*9880d681SAndroid Build Coastguard Workerentry: 73*9880d681SAndroid Build Coastguard Worker %x = alloca i32, align 4 74*9880d681SAndroid Build Coastguard Worker %ref.tmp = alloca i32, align 4 75*9880d681SAndroid Build Coastguard Worker %y = alloca i8, align 1 76*9880d681SAndroid Build Coastguard Worker %j = alloca i8, align 1 77*9880d681SAndroid Build Coastguard Worker %I = alloca i8, align 1 78*9880d681SAndroid Build Coastguard Worker %ref.tmp5 = alloca i32, align 4 79*9880d681SAndroid Build Coastguard Worker %ref.tmp6 = alloca i32, align 4 80*9880d681SAndroid Build Coastguard Worker %call11 = call i32 @_Z4condv(), !dbg !39 81*9880d681SAndroid Build Coastguard Worker %tobool12 = icmp eq i32 %call11, 0, !dbg !39 82*9880d681SAndroid Build Coastguard Worker br i1 %tobool12, label %while.end7, label %while.body, !dbg !40 83*9880d681SAndroid Build Coastguard Worker 84*9880d681SAndroid Build Coastguard Workerwhile.cond.loopexit: ; preds = %while.body4, %while.body 85*9880d681SAndroid Build Coastguard Worker %call = call i32 @_Z4condv(), !dbg !39 86*9880d681SAndroid Build Coastguard Worker %tobool = icmp eq i32 %call, 0, !dbg !39 87*9880d681SAndroid Build Coastguard Worker br i1 %tobool, label %while.end7, label %while.body, !dbg !40 88*9880d681SAndroid Build Coastguard Worker 89*9880d681SAndroid Build Coastguard Workerwhile.body: ; preds = %entry, %while.cond.loopexit 90*9880d681SAndroid Build Coastguard Worker store i32 0, i32* %ref.tmp, align 4, !dbg !41, !tbaa !42 91*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.value(metadata i32* %x, i64 0, metadata !21, metadata !DIExpression(DW_OP_deref)), !dbg !46 92*9880d681SAndroid Build Coastguard Worker call void @_Z4funcRKiS0_(i32* dereferenceable(4) %x, i32* dereferenceable(4) %ref.tmp), !dbg !47 93*9880d681SAndroid Build Coastguard Worker %call29 = call i32 @_Z4condv(), !dbg !48 94*9880d681SAndroid Build Coastguard Worker %tobool310 = icmp eq i32 %call29, 0, !dbg !48 95*9880d681SAndroid Build Coastguard Worker br i1 %tobool310, label %while.cond.loopexit, label %while.body4, !dbg !49 96*9880d681SAndroid Build Coastguard Worker 97*9880d681SAndroid Build Coastguard Workerwhile.body4: ; preds = %while.body, %while.body4 98*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.value(metadata i8* %y, i64 0, metadata !23, metadata !DIExpression(DW_OP_deref)), !dbg !50 99*9880d681SAndroid Build Coastguard Worker call void @_Z4funcPv(i8* %y), !dbg !51 100*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.value(metadata i8* %j, i64 0, metadata !26, metadata !DIExpression(DW_OP_deref)), !dbg !52 101*9880d681SAndroid Build Coastguard Worker call void @_Z4funcPv(i8* %j), !dbg !53 102*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.value(metadata i8* %I, i64 0, metadata !27, metadata !DIExpression(DW_OP_deref)), !dbg !54 103*9880d681SAndroid Build Coastguard Worker call void @_Z4funcPv(i8* %I), !dbg !55 104*9880d681SAndroid Build Coastguard Worker store i32 0, i32* %ref.tmp5, align 4, !dbg !56, !tbaa !42 105*9880d681SAndroid Build Coastguard Worker store i32 0, i32* %ref.tmp6, align 4, !dbg !57, !tbaa !42 106*9880d681SAndroid Build Coastguard Worker call void @_Z4funcRKiS0_(i32* dereferenceable(4) %ref.tmp5, i32* dereferenceable(4) %ref.tmp6), !dbg !58 107*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.declare(metadata %struct.A* undef, metadata !28, metadata !36), !dbg !59 108*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.value(metadata i32* %x, i64 0, metadata !28, metadata !33), !dbg !59 109*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.value(metadata i32* %x, i64 0, metadata !21, metadata !DIExpression(DW_OP_deref)), !dbg !46 110*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.value(metadata i32* %x, i64 0, metadata !60, metadata !33), !dbg !62 111*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.value(metadata i32 undef, i64 0, metadata !60, metadata !35), !dbg !62 112*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.declare(metadata %struct.A* undef, metadata !60, metadata !36), !dbg !62 113*9880d681SAndroid Build Coastguard Worker call void @_Z2f1Pii(i32* %x, i32 undef), !dbg !63 114*9880d681SAndroid Build Coastguard Worker %call2 = call i32 @_Z4condv(), !dbg !48 115*9880d681SAndroid Build Coastguard Worker %tobool3 = icmp eq i32 %call2, 0, !dbg !48 116*9880d681SAndroid Build Coastguard Worker br i1 %tobool3, label %while.cond.loopexit, label %while.body4, !dbg !49 117*9880d681SAndroid Build Coastguard Worker 118*9880d681SAndroid Build Coastguard Workerwhile.end7: ; preds = %while.cond.loopexit, %entry 119*9880d681SAndroid Build Coastguard Worker ret void, !dbg !64 120*9880d681SAndroid Build Coastguard Worker} 121*9880d681SAndroid Build Coastguard Worker 122*9880d681SAndroid Build Coastguard Workerdeclare i32 @_Z4condv() 123*9880d681SAndroid Build Coastguard Worker 124*9880d681SAndroid Build Coastguard Workerdeclare void @_Z4funcRKiS0_(i32* dereferenceable(4), i32* dereferenceable(4)) 125*9880d681SAndroid Build Coastguard Worker 126*9880d681SAndroid Build Coastguard Workerdeclare void @_Z4funcPv(i8*) 127*9880d681SAndroid Build Coastguard Worker 128*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind readnone 129*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1 130*9880d681SAndroid Build Coastguard Worker 131*9880d681SAndroid Build Coastguard Workerattributes #0 = { alwaysinline ssp uwtable } 132*9880d681SAndroid Build Coastguard Workerattributes #1 = { nounwind readnone } 133*9880d681SAndroid Build Coastguard Workerattributes #3 = { ssp uwtable } 134*9880d681SAndroid Build Coastguard Worker 135*9880d681SAndroid Build Coastguard Worker!llvm.dbg.cu = !{!0} 136*9880d681SAndroid Build Coastguard Worker!llvm.module.flags = !{!29, !30, !31} 137*9880d681SAndroid Build Coastguard Worker!llvm.ident = !{!32} 138*9880d681SAndroid Build Coastguard Worker 139*9880d681SAndroid Build Coastguard Worker!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.7.0 (trunk 227088) (llvm/trunk 227091)", isOptimized: true, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !3, globals: !2, imports: !2) 140*9880d681SAndroid Build Coastguard Worker!1 = !DIFile(filename: "test.cpp", directory: "") 141*9880d681SAndroid Build Coastguard Worker!2 = !{} 142*9880d681SAndroid Build Coastguard Worker!3 = !{!4} 143*9880d681SAndroid Build Coastguard Worker!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "A", line: 1, size: 128, align: 64, file: !1, elements: !5, identifier: "_ZTS1A") 144*9880d681SAndroid Build Coastguard Worker!5 = !{!6, !9} 145*9880d681SAndroid Build Coastguard Worker!6 = !DIDerivedType(tag: DW_TAG_member, name: "m1", line: 2, size: 64, align: 64, file: !1, scope: !4, baseType: !7) 146*9880d681SAndroid Build Coastguard Worker!7 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !8) 147*9880d681SAndroid Build Coastguard Worker!8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 148*9880d681SAndroid Build Coastguard Worker!9 = !DIDerivedType(tag: DW_TAG_member, name: "m2", line: 3, size: 32, align: 32, offset: 64, file: !1, scope: !4, baseType: !8) 149*9880d681SAndroid Build Coastguard Worker!11 = distinct !DISubprogram(name: "f2", linkageName: "_Z2f21A", line: 7, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 7, file: !1, scope: !12, type: !13, variables: !15) 150*9880d681SAndroid Build Coastguard Worker!12 = !DIFile(filename: "test.cpp", directory: "") 151*9880d681SAndroid Build Coastguard Worker!13 = !DISubroutineType(types: !14) 152*9880d681SAndroid Build Coastguard Worker!14 = !{null, !4} 153*9880d681SAndroid Build Coastguard Worker!15 = !{!16} 154*9880d681SAndroid Build Coastguard Worker!16 = !DILocalVariable(name: "p5", line: 7, arg: 1, scope: !11, file: !12, type: !4) 155*9880d681SAndroid Build Coastguard Worker!17 = distinct !DISubprogram(name: "f", linkageName: "_Z1fv", line: 12, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 12, file: !1, scope: !12, type: !18, variables: !20) 156*9880d681SAndroid Build Coastguard Worker!18 = !DISubroutineType(types: !19) 157*9880d681SAndroid Build Coastguard Worker!19 = !{null} 158*9880d681SAndroid Build Coastguard Worker!20 = !{!21, !23, !26, !27, !28} 159*9880d681SAndroid Build Coastguard Worker!21 = !DILocalVariable(name: "x", line: 14, scope: !22, file: !12, type: !8) 160*9880d681SAndroid Build Coastguard Worker!22 = distinct !DILexicalBlock(line: 13, column: 18, file: !1, scope: !17) 161*9880d681SAndroid Build Coastguard Worker!23 = !DILocalVariable(name: "y", line: 17, scope: !24, file: !12, type: !25) 162*9880d681SAndroid Build Coastguard Worker!24 = distinct !DILexicalBlock(line: 16, column: 20, file: !1, scope: !22) 163*9880d681SAndroid Build Coastguard Worker!25 = !DIBasicType(tag: DW_TAG_base_type, name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char) 164*9880d681SAndroid Build Coastguard Worker!26 = !DILocalVariable(name: "j", line: 19, scope: !24, file: !12, type: !25) 165*9880d681SAndroid Build Coastguard Worker!27 = !DILocalVariable(name: "I", line: 21, scope: !24, file: !12, type: !25) 166*9880d681SAndroid Build Coastguard Worker!28 = !DILocalVariable(name: "g", line: 24, scope: !24, file: !12, type: !4) 167*9880d681SAndroid Build Coastguard Worker!29 = !{i32 2, !"Dwarf Version", i32 2} 168*9880d681SAndroid Build Coastguard Worker!30 = !{i32 2, !"Debug Info Version", i32 3} 169*9880d681SAndroid Build Coastguard Worker!31 = !{i32 1, !"PIC Level", i32 2} 170*9880d681SAndroid Build Coastguard Worker!32 = !{!"clang version 3.7.0 (trunk 227088) (llvm/trunk 227091)"} 171*9880d681SAndroid Build Coastguard Worker!33 = !DIExpression(DW_OP_bit_piece, 0, 8) 172*9880d681SAndroid Build Coastguard Worker!34 = !DILocation(line: 7, column: 42, scope: !11) 173*9880d681SAndroid Build Coastguard Worker!35 = !DIExpression(DW_OP_bit_piece, 8, 4) 174*9880d681SAndroid Build Coastguard Worker!36 = !DIExpression() 175*9880d681SAndroid Build Coastguard Worker!37 = !DILocation(line: 7, column: 48, scope: !11) 176*9880d681SAndroid Build Coastguard Worker!38 = !DILocation(line: 7, column: 66, scope: !11) 177*9880d681SAndroid Build Coastguard Worker!39 = !DILocation(line: 13, column: 10, scope: !17) 178*9880d681SAndroid Build Coastguard Worker!40 = !DILocation(line: 13, column: 3, scope: !17) 179*9880d681SAndroid Build Coastguard Worker!41 = !DILocation(line: 15, column: 13, scope: !22) 180*9880d681SAndroid Build Coastguard Worker!42 = !{!43, !43, i64 0} 181*9880d681SAndroid Build Coastguard Worker!43 = !{!"int", !44, i64 0} 182*9880d681SAndroid Build Coastguard Worker!44 = !{!"omnipotent char", !45, i64 0} 183*9880d681SAndroid Build Coastguard Worker!45 = !{!"Simple C/C++ TBAA"} 184*9880d681SAndroid Build Coastguard Worker!46 = !DILocation(line: 14, column: 9, scope: !22) 185*9880d681SAndroid Build Coastguard Worker!47 = !DILocation(line: 15, column: 5, scope: !22) 186*9880d681SAndroid Build Coastguard Worker!48 = !DILocation(line: 16, column: 12, scope: !22) 187*9880d681SAndroid Build Coastguard Worker!49 = !DILocation(line: 16, column: 5, scope: !22) 188*9880d681SAndroid Build Coastguard Worker!50 = !DILocation(line: 17, column: 12, scope: !24) 189*9880d681SAndroid Build Coastguard Worker!51 = !DILocation(line: 18, column: 7, scope: !24) 190*9880d681SAndroid Build Coastguard Worker!52 = !DILocation(line: 19, column: 12, scope: !24) 191*9880d681SAndroid Build Coastguard Worker!53 = !DILocation(line: 20, column: 7, scope: !24) 192*9880d681SAndroid Build Coastguard Worker!54 = !DILocation(line: 21, column: 12, scope: !24) 193*9880d681SAndroid Build Coastguard Worker!55 = !DILocation(line: 22, column: 7, scope: !24) 194*9880d681SAndroid Build Coastguard Worker!56 = !DILocation(line: 23, column: 12, scope: !24) 195*9880d681SAndroid Build Coastguard Worker!57 = !DILocation(line: 23, column: 15, scope: !24) 196*9880d681SAndroid Build Coastguard Worker!58 = !DILocation(line: 23, column: 7, scope: !24) 197*9880d681SAndroid Build Coastguard Worker!59 = !DILocation(line: 24, column: 9, scope: !24) 198*9880d681SAndroid Build Coastguard Worker!60 = !DILocalVariable(name: "p5", line: 7, arg: 1, scope: !11, file: !12, type: !4) 199*9880d681SAndroid Build Coastguard Worker!61 = distinct !DILocation(line: 26, column: 7, scope: !24) 200*9880d681SAndroid Build Coastguard Worker!62 = !DILocation(line: 7, column: 42, scope: !11, inlinedAt: !61) 201*9880d681SAndroid Build Coastguard Worker!63 = !DILocation(line: 7, column: 48, scope: !11, inlinedAt: !61) 202*9880d681SAndroid Build Coastguard Worker!64 = !DILocation(line: 29, column: 1, scope: !17) 203