203 lines · plain
1; RUN: llc -filetype=obj < %s | llvm-dwarfdump -debug-info - | FileCheck %s2;3; PR22296: In this testcase the DBG_VALUE describing "p5" becomes unavailable4; because the register its address is in is clobbered and we (currently) aren't5; smart enough to realize that the value is rematerialized immediately after the6; DBG_VALUE and/or is actually a stack slot.7;8; Test that we handle this situation gracefully by omitting the DW_AT_location9; and not asserting.10; Note that this check may XPASS in the future if DbgValueHistoryCalculator11; becoms smarter. That would be fine, too.12;13; CHECK: DW_TAG_subprogram14; CHECK: linkage_name{{.*}}_Z2f21A15; CHECK: DW_TAG_formal_parameter16; CHECK-NOT: DW_AT_location17; CHECK-NEXT: DW_AT_name {{.*}}"p5"18;19; // Compile at -O120; struct A {21; int *m1;22; int m2;23; };24;25; void f1(int *p1, int p2);26; void __attribute__((always_inline)) f2(A p5) { f1(p5.m1, p5.m2); }27;28; void func(ptr);29; void func(const int &, const int&);30; int cond();31; void f() {32; while (cond()) {33; int x;34; func(x, 0);35; while (cond()) {36; char y;37; func(&y);38; char j;39; func(&j);40; char I;41; func(&I);42; func(0, 0);43; A g;44; g.m1 = &x;45; f2(g);46; }47; }48; }49; ModuleID = 'test.cpp'50target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"51target triple = "x86_64-apple-macosx10.10.0"52 53%struct.A = type { ptr, i32 }54 55; Function Attrs: alwaysinline ssp uwtable56define void @_Z2f21A(ptr %p5.coerce0, i32 %p5.coerce1) #0 !dbg !11 {57entry:58 tail call void @llvm.dbg.value(metadata ptr %p5.coerce0, metadata !16, metadata !33), !dbg !3459 tail call void @llvm.dbg.value(metadata i32 %p5.coerce1, metadata !16, metadata !35), !dbg !3460 tail call void @llvm.dbg.declare(metadata ptr undef, metadata !16, metadata !36), !dbg !3461 tail call void @_Z2f1Pii(ptr %p5.coerce0, i32 %p5.coerce1), !dbg !3762 ret void, !dbg !3863}64 65; Function Attrs: nounwind readnone66declare void @llvm.dbg.declare(metadata, metadata, metadata) #167 68declare void @_Z2f1Pii(ptr, i32) #269 70; Function Attrs: ssp uwtable71define void @_Z1fv() #3 !dbg !17 {72entry:73 %x = alloca i32, align 474 %ref.tmp = alloca i32, align 475 %y = alloca i8, align 176 %j = alloca i8, align 177 %I = alloca i8, align 178 %ref.tmp5 = alloca i32, align 479 %ref.tmp6 = alloca i32, align 480 %call11 = call i32 @_Z4condv(), !dbg !3981 %tobool12 = icmp eq i32 %call11, 0, !dbg !3982 br i1 %tobool12, label %while.end7, label %while.body, !dbg !4083 84while.cond.loopexit: ; preds = %while.body4, %while.body85 %call = call i32 @_Z4condv(), !dbg !3986 %tobool = icmp eq i32 %call, 0, !dbg !3987 br i1 %tobool, label %while.end7, label %while.body, !dbg !4088 89while.body: ; preds = %entry, %while.cond.loopexit90 store i32 0, ptr %ref.tmp, align 4, !dbg !41, !tbaa !4291 call void @llvm.dbg.value(metadata ptr %x, metadata !21, metadata !DIExpression(DW_OP_deref)), !dbg !4692 call void @_Z4funcRKiS0_(ptr dereferenceable(4) %x, ptr dereferenceable(4) %ref.tmp), !dbg !4793 %call29 = call i32 @_Z4condv(), !dbg !4894 %tobool310 = icmp eq i32 %call29, 0, !dbg !4895 br i1 %tobool310, label %while.cond.loopexit, label %while.body4, !dbg !4996 97while.body4: ; preds = %while.body, %while.body498 call void @llvm.dbg.value(metadata ptr %y, metadata !23, metadata !DIExpression(DW_OP_deref)), !dbg !5099 call void @_Z4funcPv(ptr %y), !dbg !51100 call void @llvm.dbg.value(metadata ptr %j, metadata !26, metadata !DIExpression(DW_OP_deref)), !dbg !52101 call void @_Z4funcPv(ptr %j), !dbg !53102 call void @llvm.dbg.value(metadata ptr %I, metadata !27, metadata !DIExpression(DW_OP_deref)), !dbg !54103 call void @_Z4funcPv(ptr %I), !dbg !55104 store i32 0, ptr %ref.tmp5, align 4, !dbg !56, !tbaa !42105 store i32 0, ptr %ref.tmp6, align 4, !dbg !57, !tbaa !42106 call void @_Z4funcRKiS0_(ptr dereferenceable(4) %ref.tmp5, ptr dereferenceable(4) %ref.tmp6), !dbg !58107 call void @llvm.dbg.declare(metadata ptr undef, metadata !28, metadata !36), !dbg !59108 call void @llvm.dbg.value(metadata ptr %x, metadata !28, metadata !33), !dbg !59109 call void @llvm.dbg.value(metadata ptr %x, metadata !21, metadata !DIExpression(DW_OP_deref)), !dbg !46110 call void @llvm.dbg.value(metadata ptr %x, metadata !60, metadata !33), !dbg !62111 call void @llvm.dbg.value(metadata i32 undef, metadata !60, metadata !35), !dbg !62112 call void @llvm.dbg.declare(metadata ptr undef, metadata !60, metadata !36), !dbg !62113 call void @_Z2f1Pii(ptr %x, i32 undef), !dbg !63114 %call2 = call i32 @_Z4condv(), !dbg !48115 %tobool3 = icmp eq i32 %call2, 0, !dbg !48116 br i1 %tobool3, label %while.cond.loopexit, label %while.body4, !dbg !49117 118while.end7: ; preds = %while.cond.loopexit, %entry119 ret void, !dbg !64120}121 122declare i32 @_Z4condv()123 124declare void @_Z4funcRKiS0_(ptr dereferenceable(4), ptr dereferenceable(4))125 126declare void @_Z4funcPv(ptr)127 128; Function Attrs: nounwind readnone129declare void @llvm.dbg.value(metadata, metadata, metadata) #1130 131attributes #0 = { alwaysinline ssp uwtable }132attributes #1 = { nounwind readnone }133attributes #3 = { ssp uwtable }134 135!llvm.dbg.cu = !{!0}136!llvm.module.flags = !{!29, !30, !31}137!llvm.ident = !{!32}138 139!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!1 = !DIFile(filename: "test.cpp", directory: "")141!2 = !{}142!3 = !{!4}143!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "A", line: 1, size: 128, align: 64, file: !1, elements: !5, identifier: "_ZTS1A")144!5 = !{!6, !9}145!6 = !DIDerivedType(tag: DW_TAG_member, name: "m1", line: 2, size: 64, align: 64, file: !1, scope: !4, baseType: !7)146!7 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !8)147!8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)148!9 = !DIDerivedType(tag: DW_TAG_member, name: "m2", line: 3, size: 32, align: 32, offset: 64, file: !1, scope: !4, baseType: !8)149!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, retainedNodes: !15)150!12 = !DIFile(filename: "test.cpp", directory: "")151!13 = !DISubroutineType(types: !14)152!14 = !{null, !4}153!15 = !{!16}154!16 = !DILocalVariable(name: "p5", line: 7, arg: 1, scope: !11, file: !12, type: !4)155!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, retainedNodes: !20)156!18 = !DISubroutineType(types: !19)157!19 = !{null}158!20 = !{!21, !23, !26, !27, !28}159!21 = !DILocalVariable(name: "x", line: 14, scope: !22, file: !12, type: !8)160!22 = distinct !DILexicalBlock(line: 13, column: 18, file: !1, scope: !17)161!23 = !DILocalVariable(name: "y", line: 17, scope: !24, file: !12, type: !25)162!24 = distinct !DILexicalBlock(line: 16, column: 20, file: !1, scope: !22)163!25 = !DIBasicType(tag: DW_TAG_base_type, name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)164!26 = !DILocalVariable(name: "j", line: 19, scope: !24, file: !12, type: !25)165!27 = !DILocalVariable(name: "I", line: 21, scope: !24, file: !12, type: !25)166!28 = !DILocalVariable(name: "g", line: 24, scope: !24, file: !12, type: !4)167!29 = !{i32 2, !"Dwarf Version", i32 2}168!30 = !{i32 2, !"Debug Info Version", i32 3}169!31 = !{i32 1, !"PIC Level", i32 2}170!32 = !{!"clang version 3.7.0 (trunk 227088) (llvm/trunk 227091)"}171!33 = !DIExpression(DW_OP_LLVM_fragment, 0, 8)172!34 = !DILocation(line: 7, column: 42, scope: !11)173!35 = !DIExpression(DW_OP_LLVM_fragment, 8, 4)174!36 = !DIExpression()175!37 = !DILocation(line: 7, column: 48, scope: !11)176!38 = !DILocation(line: 7, column: 66, scope: !11)177!39 = !DILocation(line: 13, column: 10, scope: !17)178!40 = !DILocation(line: 13, column: 3, scope: !17)179!41 = !DILocation(line: 15, column: 13, scope: !22)180!42 = !{!43, !43, i64 0}181!43 = !{!"int", !44, i64 0}182!44 = !{!"omnipotent char", !45, i64 0}183!45 = !{!"Simple C/C++ TBAA"}184!46 = !DILocation(line: 14, column: 9, scope: !22)185!47 = !DILocation(line: 15, column: 5, scope: !22)186!48 = !DILocation(line: 16, column: 12, scope: !22)187!49 = !DILocation(line: 16, column: 5, scope: !22)188!50 = !DILocation(line: 17, column: 12, scope: !24)189!51 = !DILocation(line: 18, column: 7, scope: !24)190!52 = !DILocation(line: 19, column: 12, scope: !24)191!53 = !DILocation(line: 20, column: 7, scope: !24)192!54 = !DILocation(line: 21, column: 12, scope: !24)193!55 = !DILocation(line: 22, column: 7, scope: !24)194!56 = !DILocation(line: 23, column: 12, scope: !24)195!57 = !DILocation(line: 23, column: 15, scope: !24)196!58 = !DILocation(line: 23, column: 7, scope: !24)197!59 = !DILocation(line: 24, column: 9, scope: !24)198!60 = !DILocalVariable(name: "p5", line: 7, arg: 1, scope: !11, file: !12, type: !4)199!61 = distinct !DILocation(line: 26, column: 7, scope: !24)200!62 = !DILocation(line: 7, column: 42, scope: !11, inlinedAt: !61)201!63 = !DILocation(line: 7, column: 48, scope: !11, inlinedAt: !61)202!64 = !DILocation(line: 29, column: 1, scope: !17)203