1# RUN: llc -O1 -start-before=greedy -stop-after=virtregrewriter -o /dev/null %s -debug-only=livedebugvars 2>&1 | FileCheck -check-prefix=CHECKDBG %s 2 3# REQUIRES: asserts 4 5# This test case was generated by using the following c program: 6# extern void foo(int, int); 7# 8# int bar[2] = {1, 2}; 9# 10# int main(int argc, char** argv) 11# { 12# int a0 = bar[0]; 13# int a1 = bar[1]; 14# foo(a0, a1); 15# return 0; 16# } 17# 18# It was compiled with -g and -O1, and the mir was dumped before ra greedy. 19 20--- | 21 ; ModuleID = 'live-debug-vars-unused-arg.ll' 22 source_filename = "live-debug-vars-unused-arg.c" 23 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 24 target triple = "x86_64-unknown-linux-gnu" 25 26 @bar = local_unnamed_addr global [2 x i32] [i32 1, i32 2], align 4, !dbg !0 27 28 ; Function Attrs: nounwind uwtable 29 define i32 @main(i32 %argc, i8** nocapture readnone %argv) local_unnamed_addr #0 !dbg !14 { 30 entry: 31 tail call void @llvm.dbg.value(metadata i32 %argc, metadata !21, metadata !DIExpression()), !dbg !25 32 tail call void @llvm.dbg.value(metadata i8** %argv, metadata !22, metadata !DIExpression()), !dbg !26 33 %0 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @bar, i64 0, i64 0), align 4, !dbg !27, !tbaa !28 34 tail call void @llvm.dbg.value(metadata i32 %0, metadata !23, metadata !DIExpression()), !dbg !32 35 %1 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @bar, i64 0, i64 1), align 4, !dbg !33, !tbaa !28 36 tail call void @llvm.dbg.value(metadata i32 %1, metadata !24, metadata !DIExpression()), !dbg !34 37 tail call void @foo(i32 %0, i32 %1) #2, !dbg !35 38 ret i32 0, !dbg !36 39 } 40 41 declare void @foo(i32, i32) local_unnamed_addr 42 43 ; Function Attrs: nounwind readnone speculatable 44 declare void @llvm.dbg.value(metadata, metadata, metadata) #1 45 46 ; Function Attrs: nounwind 47 declare void @llvm.stackprotector(i8*, i8**) #2 48 49 attributes #0 = { nounwind uwtable } 50 attributes #1 = { nounwind readnone speculatable } 51 attributes #2 = { nounwind } 52 53 !llvm.dbg.cu = !{!2} 54 !llvm.module.flags = !{!10, !11, !12} 55 !llvm.ident = !{!13} 56 57 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 58 !1 = distinct !DIGlobalVariable(name: "bar", scope: !2, file: !3, line: 3, type: !6, isLocal: false, isDefinition: true) 59 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 6.0.0 (trunk 313866) (llvm/trunk 313875)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5) 60 !3 = !DIFile(filename: "live-debug-vars-unused-arg.c", directory: "/repo/uabbpet/master") 61 !4 = !{} 62 !5 = !{!0} 63 !6 = !DICompositeType(tag: DW_TAG_array_type, baseType: !7, size: 64, elements: !8) 64 !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 65 !8 = !{!9} 66 !9 = !DISubrange(count: 2) 67 !10 = !{i32 2, !"Dwarf Version", i32 4} 68 !11 = !{i32 2, !"Debug Info Version", i32 3} 69 !12 = !{i32 1, !"wchar_size", i32 4} 70 !13 = !{!"clang version 6.0.0 (trunk 313866) (llvm/trunk 313875)"} 71 !14 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 5, type: !15, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !2, retainedNodes: !20) 72 !15 = !DISubroutineType(types: !16) 73 !16 = !{!7, !7, !17} 74 !17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !18, size: 64) 75 !18 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !19, size: 64) 76 !19 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) 77 !20 = !{!21, !22, !23, !24} 78 !21 = !DILocalVariable(name: "argc", arg: 1, scope: !14, file: !3, line: 5, type: !7) 79 !22 = !DILocalVariable(name: "argv", arg: 2, scope: !14, file: !3, line: 5, type: !17) 80 !23 = !DILocalVariable(name: "a0", scope: !14, file: !3, line: 7, type: !7) 81 !24 = !DILocalVariable(name: "a1", scope: !14, file: !3, line: 8, type: !7) 82 !25 = !DILocation(line: 5, column: 14, scope: !14) 83 !26 = !DILocation(line: 5, column: 27, scope: !14) 84 !27 = !DILocation(line: 7, column: 12, scope: !14) 85 !28 = !{!29, !29, i64 0} 86 !29 = !{!"int", !30, i64 0} 87 !30 = !{!"omnipotent char", !31, i64 0} 88 !31 = !{!"Simple C/C++ TBAA"} 89 !32 = !DILocation(line: 7, column: 7, scope: !14) 90 !33 = !DILocation(line: 8, column: 12, scope: !14) 91 !34 = !DILocation(line: 8, column: 7, scope: !14) 92 !35 = !DILocation(line: 9, column: 3, scope: !14) 93 !36 = !DILocation(line: 10, column: 3, scope: !14) 94 95... 96--- 97name: main 98alignment: 4 99exposesReturnsTwice: false 100legalized: false 101regBankSelected: false 102selected: false 103tracksRegLiveness: true 104registers: 105 - { id: 0, class: gr32, preferred-register: '' } 106 - { id: 1, class: gr64, preferred-register: '' } 107 - { id: 2, class: gr32, preferred-register: '' } 108 - { id: 3, class: gr32, preferred-register: '' } 109 - { id: 4, class: gr32, preferred-register: '' } 110liveins: 111frameInfo: 112 isFrameAddressTaken: false 113 isReturnAddressTaken: false 114 hasStackMap: false 115 hasPatchPoint: false 116 stackSize: 0 117 offsetAdjustment: 0 118 maxAlignment: 0 119 adjustsStack: false 120 hasCalls: true 121 stackProtector: '' 122 maxCallFrameSize: 4294967295 123 hasOpaqueSPAdjustment: false 124 hasVAStart: false 125 hasMustTailInVarArgFunc: false 126 savePoint: '' 127 restorePoint: '' 128fixedStack: 129stack: 130constants: 131body: | 132 bb.0.entry: 133 DBG_VALUE debug-use $edi, debug-use _, !21, !DIExpression(), debug-location !25 134 DBG_VALUE debug-use $rsi, debug-use _, !22, !DIExpression(), debug-location !26 135 %2 = MOV32rm $rip, 1, _, @bar, _, debug-location !27 :: (dereferenceable load 4 from `i32* getelementptr inbounds ([2 x i32], [2 x i32]* @bar, i64 0, i64 0)`, !tbaa !28) 136 DBG_VALUE debug-use %2, debug-use _, !23, !DIExpression(), debug-location !32 137 %3 = MOV32rm $rip, 1, _, @bar + 4, _, debug-location !33 :: (dereferenceable load 4 from `i32* getelementptr inbounds ([2 x i32], [2 x i32]* @bar, i64 0, i64 1)`, !tbaa !28) 138 DBG_VALUE debug-use %3, debug-use _, !24, !DIExpression(), debug-location !34 139 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !35 140 $edi = COPY %2, debug-location !35 141 $esi = COPY %3, debug-location !35 142 CALL64pcrel32 @foo, csr_64, implicit $rsp, implicit $ssp, implicit killed $edi, implicit killed $esi, implicit-def $rsp, debug-location !35 143 ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !35 144 $eax = MOV32r0 implicit-def dead $eflags, debug-location !36 145 RET 0, killed $eax, debug-location !36 146 147... 148 149# Let's verify that the slot index ranges for the unused variables argc/argv, 150# connected to physical regs $edi and $rsi, does not overlap with the ranges 151# for %2 and %3. The register allocator is actually allocating the 152# virtual registers # to $edi and $esi, so the ranges for argc/argv should 153# not cover the whole BB. 154# 155# CHECKDBG-LABEL: ********** EMITTING LIVE DEBUG VARIABLES ********** 156# CHECKDBG-NEXT: !"argc,5" [0B;0e):0 Loc0=debug-use $edi 157# CHECKDBG-NEXT: [0B;0e):0 %bb.0-160B 158# CHECKDBG-NEXT: !"argv,5" [0B;0e):0 Loc0=debug-use $rsi 159# CHECKDBG-NEXT: [0B;0e):0 %bb.0-160B 160# CHECKDBG-NEXT: !"a0,7" [16r;64r):0 Loc0=debug-use %2 161# CHECKDBG-NEXT: [16r;64r):0 %bb.0-160B 162# CHECKDBG-NEXT: !"a1,8" [32r;80r):0 Loc0=debug-use %3 163# CHECKDBG-NEXT: [32r;80r):0 %bb.0-160B 164