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