1; RUN: llc -mtriple=x86_64-unknown-linux-gnu -start-after=codegenprepare -stop-before=finalize-isel -o - %s | FileCheck %s 2 3; Input to this test looked like this and was compiled using: clang -g -O1 -mllvm -stop-after=codegenprepare -S 4; 5; extern void bar(int); 6; 7; void foo_local(int t1a) { 8; int local = 123; 9; bar(local); 10; local = t1a; 11; bar(local); 12; } 13; 14; void foo_other_param(int t2a, int t2b) { 15; bar(t2b); 16; t2b = 123; 17; bar(t2b); 18; t2b = t2a; 19; bar(t2b); 20; } 21; 22; void foo_same_param(int t3a) { 23; bar(t3a); 24; int tmp = t3a; 25; t3a = 123; 26; bar(t3a); 27; t3a = tmp; 28; bar(t3a); 29; } 30; 31 32; Catch metadata references for involved variables. 33; 34; CHECK-DAG: ![[T1A:.*]] = !DILocalVariable(name: "t1a" 35; CHECK-DAG: ![[LOCAL:.*]] = !DILocalVariable(name: "local" 36; CHECK-DAG: ![[T2A:.*]] = !DILocalVariable(name: "t2a" 37; CHECK-DAG: ![[T2B:.*]] = !DILocalVariable(name: "t2b" 38; CHECK-DAG: ![[T3A:.*]] = !DILocalVariable(name: "t3a" 39; CHECK-DAG: ![[TMP:.*]] = !DILocalVariable(name: "tmp" 40 41 42define dso_local void @foo_local(i32 %t1a) local_unnamed_addr #0 !dbg !7 { 43; CHECK-LABEL: name: foo_local 44; CHECK-NOT: DBG_VALUE 45; CHECK: DBG_VALUE $edi, $noreg, ![[T1A]], !DIExpression(), 46; CHECK-NEXT: %0:gr32 = COPY $edi 47; CHECK-NEXT: DBG_VALUE %0, $noreg, ![[T1A]], !DIExpression(), 48; CHECK-NEXT: DBG_VALUE 123, $noreg, ![[LOCAL]], !DIExpression(), 49; CHECK-NOT: DBG_VALUE 50; CHECK: CALL64pcrel32 @bar, 51; CHECK: DBG_VALUE %0, $noreg, ![[LOCAL]], !DIExpression(), 52; CHECK: DBG_VALUE $edi, $noreg, ![[T1A]], !DIExpression(), 53; CHECK-NOT: DBG_VALUE 54; CHECK: TCRETURNdi64 @bar, 55entry: 56 call void @llvm.dbg.value(metadata i32 %t1a, metadata !12, metadata !DIExpression()), !dbg !14 57 call void @llvm.dbg.value(metadata i32 123, metadata !13, metadata !DIExpression()), !dbg !15 58 tail call void @bar(i32 123) #3, !dbg !16 59 call void @llvm.dbg.value(metadata i32 %t1a, metadata !13, metadata !DIExpression()), !dbg !15 60 tail call void @bar(i32 %t1a) #3, !dbg !17 61 ret void, !dbg !18 62} 63 64define dso_local void @foo_other_param(i32 %t2a, i32 %t2b) local_unnamed_addr #0 !dbg !19 { 65; CHECK-LABEL: name: foo_other_param 66; CHECK: DBG_VALUE $edi, $noreg, ![[T2A]], !DIExpression(), 67; CHECK: DBG_VALUE $esi, $noreg, ![[T2B]], !DIExpression(), 68; CHECK: %1:gr32 = COPY $esi 69; CHECK: DBG_VALUE %1, $noreg, ![[T2B]], !DIExpression(), 70; CHECK: %0:gr32 = COPY $edi 71; CHECK: DBG_VALUE %0, $noreg, ![[T2A]], !DIExpression(), 72; CHECK: DBG_VALUE $edi, $noreg, ![[T2B]], !DIExpression(), 73; CHECK: CALL64pcrel32 @bar, 74; CHECK: DBG_VALUE 123, $noreg, ![[T2B]], !DIExpression(), 75; CHECK: CALL64pcrel32 @bar, 76; CHECK: DBG_VALUE %0, $noreg, ![[T2B]], !DIExpression(), 77; CHECK: DBG_VALUE $edi, $noreg, ![[T2A]], !DIExpression(), 78; CHECK: TCRETURNdi64 @bar, 79 80entry: 81 call void @llvm.dbg.value(metadata i32 %t2a, metadata !23, metadata !DIExpression()), !dbg !25 82 call void @llvm.dbg.value(metadata i32 %t2b, metadata !24, metadata !DIExpression()), !dbg !26 83 tail call void @bar(i32 %t2b) #3, !dbg !27 84 call void @llvm.dbg.value(metadata i32 123, metadata !24, metadata !DIExpression()), !dbg !26 85 tail call void @bar(i32 123) #3, !dbg !28 86 call void @llvm.dbg.value(metadata i32 %t2a, metadata !24, metadata !DIExpression()), !dbg !26 87 tail call void @bar(i32 %t2a) #3, !dbg !29 88 ret void, !dbg !30 89} 90 91define dso_local void @foo_same_param(i32 %t3a) local_unnamed_addr #0 !dbg !31 { 92; CHECK-LABEL: name: foo_same_param 93; CHECK: DBG_VALUE $edi, $noreg, ![[T3A]], !DIExpression(), 94; CHECK: %0:gr32 = COPY $edi 95; CHECK: DBG_VALUE %0, $noreg, ![[T3A]], !DIExpression(), 96; CHECK: CALL64pcrel32 @bar, 97; CHECK: DBG_VALUE %0, $noreg, ![[TMP]], !DIExpression(), 98; CHECK: DBG_VALUE 123, $noreg, ![[T3A]], !DIExpression(), 99; CHECK: CALL64pcrel32 @bar, 100; CHECK: DBG_VALUE %0, $noreg, ![[T3A]], !DIExpression(), 101; CHECK: TCRETURNdi64 @bar, 102entry: 103 call void @llvm.dbg.value(metadata i32 %t3a, metadata !33, metadata !DIExpression()), !dbg !35 104 tail call void @bar(i32 %t3a) #3, !dbg !36 105 call void @llvm.dbg.value(metadata i32 %t3a, metadata !34, metadata !DIExpression()), !dbg !37 106 call void @llvm.dbg.value(metadata i32 123, metadata !33, metadata !DIExpression()), !dbg !35 107 tail call void @bar(i32 123) #3, !dbg !38 108 call void @llvm.dbg.value(metadata i32 %t3a, metadata !33, metadata !DIExpression()), !dbg !35 109 tail call void @bar(i32 %t3a) #3, !dbg !39 110 ret void, !dbg !40 111} 112 113declare void @llvm.dbg.value(metadata, metadata, metadata) #2 114 115declare dso_local void @bar(i32) local_unnamed_addr 116 117attributes #0 = { nounwind uwtable } 118attributes #2 = { nounwind readnone speculatable } 119attributes #3 = { nounwind } 120 121!llvm.dbg.cu = !{!0} 122!llvm.module.flags = !{!3, !4, !5} 123!llvm.ident = !{!6} 124 125!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None) 126!1 = !DIFile(filename: "foo.c", directory: "") 127!2 = !{} 128!3 = !{i32 2, !"Dwarf Version", i32 4} 129!4 = !{i32 2, !"Debug Info Version", i32 3} 130!5 = !{i32 1, !"wchar_size", i32 4} 131!6 = !{!"clang version 9.0.0"} 132!7 = distinct !DISubprogram(name: "foo_local", scope: !1, file: !1, line: 3, type: !8, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11) 133!8 = !DISubroutineType(types: !9) 134!9 = !{null, !10} 135!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 136!11 = !{!12, !13} 137!12 = !DILocalVariable(name: "t1a", arg: 1, scope: !7, file: !1, line: 3, type: !10) 138!13 = !DILocalVariable(name: "local", scope: !7, file: !1, line: 4, type: !10) 139!14 = !DILocation(line: 3, column: 20, scope: !7) 140!15 = !DILocation(line: 4, column: 7, scope: !7) 141!16 = !DILocation(line: 5, column: 3, scope: !7) 142!17 = !DILocation(line: 7, column: 3, scope: !7) 143!18 = !DILocation(line: 8, column: 1, scope: !7) 144!19 = distinct !DISubprogram(name: "foo_other_param", scope: !1, file: !1, line: 10, type: !20, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !22) 145!20 = !DISubroutineType(types: !21) 146!21 = !{null, !10, !10} 147!22 = !{!23, !24} 148!23 = !DILocalVariable(name: "t2a", arg: 1, scope: !19, file: !1, line: 10, type: !10) 149!24 = !DILocalVariable(name: "t2b", arg: 2, scope: !19, file: !1, line: 10, type: !10) 150!25 = !DILocation(line: 10, column: 26, scope: !19) 151!26 = !DILocation(line: 10, column: 35, scope: !19) 152!27 = !DILocation(line: 11, column: 3, scope: !19) 153!28 = !DILocation(line: 13, column: 3, scope: !19) 154!29 = !DILocation(line: 15, column: 3, scope: !19) 155!30 = !DILocation(line: 16, column: 1, scope: !19) 156!31 = distinct !DISubprogram(name: "foo_same_param", scope: !1, file: !1, line: 18, type: !8, scopeLine: 18, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !32) 157!32 = !{!33, !34} 158!33 = !DILocalVariable(name: "t3a", arg: 1, scope: !31, file: !1, line: 18, type: !10) 159!34 = !DILocalVariable(name: "tmp", scope: !31, file: !1, line: 20, type: !10) 160!35 = !DILocation(line: 18, column: 25, scope: !31) 161!36 = !DILocation(line: 19, column: 3, scope: !31) 162!37 = !DILocation(line: 20, column: 7, scope: !31) 163!38 = !DILocation(line: 22, column: 3, scope: !31) 164!39 = !DILocation(line: 24, column: 3, scope: !31) 165!40 = !DILocation(line: 25, column: 1, scope: !31) 166