1# RUN: llc -mtriple=arm-eabi -run-pass=livedebugvalues %s -o - | FileCheck %s 2# 3# Check that the debug information for variables are propagated into the correct blocks. 4# 5# Generated from the C source: 6# 7# int func2(int, int); 8# void func(int a) { 9# int b = func2(10, 11); 10# if (a) { 11# int c = func2(12, 13); 12# for(int i = 1; i < a; i++) { 13# func2(i, i+b); 14# } 15# func2(b,c); 16# } 17# func2(b,a); 18# } 19 20# CHECK: [[VAR_A:![0-9]+]] = !DILocalVariable(name: "a", 21# CHECK: [[VAR_B:![0-9]+]] = !DILocalVariable(name: "b", 22# CHECK: [[VAR_C:![0-9]+]] = !DILocalVariable(name: "c", 23# CHECK: [[VAR_I:![0-9]+]] = !DILocalVariable(name: "i", 24 25# CHECK: bb.0.entry 26# CHECK: DBG_VALUE debug-use %r0, debug-use _, [[VAR_A]] 27# CHECK: DBG_VALUE debug-use [[REG_A:%r[0-9]+]], debug-use _, [[VAR_A]] 28# CHECK: DBG_VALUE debug-use [[REG_B:%r[0-9]+]], debug-use _, [[VAR_B]] 29 30# CHECK: bb.1.if.then 31# CHECK: DBG_VALUE debug-use [[REG_B]], debug-use _, [[VAR_B]] 32# CHECK: DBG_VALUE debug-use [[REG_A]], debug-use _, [[VAR_A]] 33# CHECK: DBG_VALUE debug-use [[REG_C:%r[0-9]+]], debug-use _, [[VAR_C]] 34# CHECK: DBG_VALUE 1, 0, [[VAR_I]] 35 36# CHECK: bb.2.for.body 37# CHECK: DBG_VALUE debug-use [[REG_I:%r[0-9]+]], debug-use _, [[VAR_I]] 38# CHECK: DBG_VALUE debug-use [[REG_C]], debug-use _, [[VAR_C]] 39# CHECK: DBG_VALUE debug-use [[REG_B]], debug-use _, [[VAR_B]] 40# CHECK: DBG_VALUE debug-use [[REG_A]], debug-use _, [[VAR_A]] 41# CHECK: DBG_VALUE debug-use [[REG_I]], debug-use _, [[VAR_I]] 42 43# CHECK: bb.3.for.cond 44# CHECK: DBG_VALUE debug-use [[REG_C]], debug-use _, [[VAR_C]] 45# CHECK: DBG_VALUE debug-use [[REG_B]], debug-use _, [[VAR_B]] 46# CHECK: DBG_VALUE debug-use [[REG_A]], debug-use _, [[VAR_A]] 47# CHECK: DBG_VALUE debug-use [[REG_I]], debug-use _, [[VAR_I]] 48 49# CHECK: bb.4.for.cond.cleanup 50# CHECK: DBG_VALUE debug-use [[REG_C]], debug-use _, [[VAR_C]] 51# CHECK: DBG_VALUE debug-use [[REG_B]], debug-use _, [[VAR_B]] 52# CHECK: DBG_VALUE debug-use [[REG_A]], debug-use _, [[VAR_A]] 53 54# CHECK: bb.5.if.end 55# CHECK: DBG_VALUE debug-use [[REG_B]], debug-use _, [[VAR_B]] 56# CHECK: DBG_VALUE debug-use [[REG_A]], debug-use _, [[VAR_A]] 57--- | 58 ; ModuleID = '/data/kwalker/work/OpenSource-llvm/llvm/test/CodeGen/ARM/dbg-range-extension.ll' 59 source_filename = "/data/kwalker/work/OpenSource-llvm/llvm/test/CodeGen/ARM/dbg-range-extension.ll" 60 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" 61 target triple = "arm---eabi" 62 63 ; Function Attrs: minsize nounwind optsize 64 define void @func(i32 %a) local_unnamed_addr #0 !dbg !8 { 65 entry: 66 tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !13, metadata !20), !dbg !21 67 %call = tail call i32 @func2(i32 10, i32 11) #0, !dbg !22 68 tail call void @llvm.dbg.value(metadata i32 %call, i64 0, metadata !14, metadata !20), !dbg !23 69 %tobool = icmp eq i32 %a, 0, !dbg !24 70 br i1 %tobool, label %if.end, label %if.then, !dbg !25 71 72 if.then: ; preds = %entry 73 %call1 = tail call i32 @func2(i32 12, i32 13) #0, !dbg !26 74 tail call void @llvm.dbg.value(metadata i32 %call1, i64 0, metadata !15, metadata !20), !dbg !27 75 tail call void @llvm.dbg.value(metadata i32 1, i64 0, metadata !18, metadata !20), !dbg !28 76 br label %for.cond, !dbg !29 77 78 for.cond: ; preds = %for.body, %if.then 79 %i.0 = phi i32 [ 1, %if.then ], [ %inc, %for.body ] 80 tail call void @llvm.dbg.value(metadata i32 %i.0, i64 0, metadata !18, metadata !20), !dbg !28 81 %cmp = icmp slt i32 %i.0, %a, !dbg !30 82 br i1 %cmp, label %for.body, label %for.cond.cleanup, !dbg !33 83 84 for.cond.cleanup: ; preds = %for.cond 85 %call3 = tail call i32 @func2(i32 %call, i32 %call1) #0, !dbg !34 86 br label %if.end, !dbg !35 87 88 for.body: ; preds = %for.cond 89 %0 = add i32 %call, %i.0, !dbg !36 90 %call2 = tail call i32 @func2(i32 %i.0, i32 %0) #0, !dbg !36 91 %inc = add nuw nsw i32 %i.0, 1, !dbg !38 92 tail call void @llvm.dbg.value(metadata i32 %inc, i64 0, metadata !18, metadata !20), !dbg !28 93 br label %for.cond, !dbg !40, !llvm.loop !41 94 95 if.end: ; preds = %for.cond.cleanup, %entry 96 %call4 = tail call i32 @func2(i32 %call, i32 %a) #0, !dbg !43 97 ret void, !dbg !44 98 } 99 100 ; Function Attrs: minsize optsize 101 declare i32 @func2(i32, i32) local_unnamed_addr #1 102 103 ; Function Attrs: nounwind readnone 104 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #2 105 106 ; Function Attrs: nounwind 107 declare void @llvm.stackprotector(i8*, i8**) #3 108 109 attributes #0 = { minsize nounwind optsize } 110 attributes #1 = { minsize optsize } 111 attributes #2 = { nounwind readnone } 112 attributes #3 = { nounwind } 113 114 !llvm.dbg.cu = !{!0} 115 !llvm.module.flags = !{!3, !4, !5, !6} 116 !llvm.ident = !{!7} 117 118 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) 119 !1 = !DIFile(filename: "loop.c", directory: "/tmp") 120 !2 = !{} 121 !3 = !{i32 2, !"Dwarf Version", i32 4} 122 !4 = !{i32 2, !"Debug Info Version", i32 3} 123 !5 = !{i32 1, !"wchar_size", i32 4} 124 !6 = !{i32 1, !"min_enum_size", i32 4} 125 !7 = !{!"clang version 4.0.0 (http://llvm.org/git/clang.git b8f10df3679b36f51e1de7c4351b82d297825089) (http://llvm.org/git/llvm.git c2a5d16d1e3b8c49f5bbb1ff87a76ac4f88edb89)"} 126 !8 = distinct !DISubprogram(name: "func", scope: !1, file: !1, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !12) 127 !9 = !DISubroutineType(types: !10) 128 !10 = !{null, !11} 129 !11 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 130 !12 = !{!13, !14, !15, !18} 131 !13 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !1, line: 2, type: !11) 132 !14 = !DILocalVariable(name: "b", scope: !8, file: !1, line: 3, type: !11) 133 !15 = !DILocalVariable(name: "c", scope: !16, file: !1, line: 5, type: !11) 134 !16 = distinct !DILexicalBlock(scope: !17, file: !1, line: 4, column: 9) 135 !17 = distinct !DILexicalBlock(scope: !8, file: !1, line: 4, column: 6) 136 !18 = !DILocalVariable(name: "i", scope: !19, file: !1, line: 6, type: !11) 137 !19 = distinct !DILexicalBlock(scope: !16, file: !1, line: 6, column: 3) 138 !20 = !DIExpression() 139 !21 = !DILocation(line: 2, column: 15, scope: !8) 140 !22 = !DILocation(line: 3, column: 17, scope: !8) 141 !23 = !DILocation(line: 3, column: 13, scope: !8) 142 !24 = !DILocation(line: 4, column: 6, scope: !17) 143 !25 = !DILocation(line: 4, column: 6, scope: !8) 144 !26 = !DILocation(line: 5, column: 11, scope: !16) 145 !27 = !DILocation(line: 5, column: 7, scope: !16) 146 !28 = !DILocation(line: 6, column: 11, scope: !19) 147 !29 = !DILocation(line: 6, column: 7, scope: !19) 148 !30 = !DILocation(line: 6, column: 20, scope: !31) 149 !31 = !DILexicalBlockFile(scope: !32, file: !1, discriminator: 1) 150 !32 = distinct !DILexicalBlock(scope: !19, file: !1, line: 6, column: 3) 151 !33 = !DILocation(line: 6, column: 3, scope: !31) 152 !34 = !DILocation(line: 9, column: 3, scope: !16) 153 !35 = !DILocation(line: 10, column: 2, scope: !16) 154 !36 = !DILocation(line: 7, column: 4, scope: !37) 155 !37 = distinct !DILexicalBlock(scope: !32, file: !1, line: 6, column: 30) 156 !38 = !DILocation(line: 6, column: 26, scope: !39) 157 !39 = !DILexicalBlockFile(scope: !32, file: !1, discriminator: 3) 158 !40 = !DILocation(line: 6, column: 3, scope: !39) 159 !41 = distinct !{!41, !42} 160 !42 = !DILocation(line: 6, column: 3, scope: !16) 161 !43 = !DILocation(line: 11, column: 2, scope: !8) 162 !44 = !DILocation(line: 12, column: 1, scope: !8) 163 164... 165--- 166name: func 167alignment: 2 168exposesReturnsTwice: false 169legalized: false 170regBankSelected: false 171selected: false 172tracksRegLiveness: false 173liveins: 174 - { reg: '%r0' } 175calleeSavedRegisters: [ '%lr', '%d8', '%d9', '%d10', '%d11', '%d12', '%d13', 176 '%d14', '%d15', '%q4', '%q5', '%q6', '%q7', '%r4', 177 '%r5', '%r6', '%r7', '%r8', '%r9', '%r10', '%r11', 178 '%s16', '%s17', '%s18', '%s19', '%s20', '%s21', 179 '%s22', '%s23', '%s24', '%s25', '%s26', '%s27', 180 '%s28', '%s29', '%s30', '%s31', '%d8_d10', '%d9_d11', 181 '%d10_d12', '%d11_d13', '%d12_d14', '%d13_d15', 182 '%q4_q5', '%q5_q6', '%q6_q7', '%q4_q5_q6_q7', '%r4_r5', 183 '%r6_r7', '%r8_r9', '%r10_r11', '%d8_d9_d10', '%d9_d10_d11', 184 '%d10_d11_d12', '%d11_d12_d13', '%d12_d13_d14', 185 '%d13_d14_d15', '%d8_d10_d12', '%d9_d11_d13', '%d10_d12_d14', 186 '%d11_d13_d15', '%d8_d10_d12_d14', '%d9_d11_d13_d15', 187 '%d9_d10', '%d11_d12', '%d13_d14', '%d9_d10_d11_d12', 188 '%d11_d12_d13_d14' ] 189frameInfo: 190 isFrameAddressTaken: false 191 isReturnAddressTaken: false 192 hasStackMap: false 193 hasPatchPoint: false 194 stackSize: 24 195 offsetAdjustment: 0 196 maxAlignment: 4 197 adjustsStack: true 198 hasCalls: true 199 maxCallFrameSize: 0 200 hasOpaqueSPAdjustment: false 201 hasVAStart: false 202 hasMustTailInVarArgFunc: false 203stack: 204 - { id: 0, type: spill-slot, offset: -4, size: 4, alignment: 4, callee-saved-register: '%lr' } 205 - { id: 1, type: spill-slot, offset: -8, size: 4, alignment: 4, callee-saved-register: '%r11' } 206 - { id: 2, type: spill-slot, offset: -12, size: 4, alignment: 4, callee-saved-register: '%r7' } 207 - { id: 3, type: spill-slot, offset: -16, size: 4, alignment: 4, callee-saved-register: '%r6' } 208 - { id: 4, type: spill-slot, offset: -20, size: 4, alignment: 4, callee-saved-register: '%r5' } 209 - { id: 5, type: spill-slot, offset: -24, size: 4, alignment: 4, callee-saved-register: '%r4' } 210body: | 211 bb.0.entry: 212 successors: %bb.5.if.end, %bb.1.if.then 213 liveins: %r0, %r4, %r5, %r6, %r7, %r11, %lr 214 215 %sp = frame-setup STMDB_UPD %sp, 14, _, killed %r4, killed %r5, killed %r6, killed %r7, killed %r11, killed %lr 216 frame-setup CFI_INSTRUCTION def_cfa_offset 24 217 frame-setup CFI_INSTRUCTION offset %lr, -4 218 frame-setup CFI_INSTRUCTION offset %r11, -8 219 frame-setup CFI_INSTRUCTION offset %r7, -12 220 frame-setup CFI_INSTRUCTION offset %r6, -16 221 frame-setup CFI_INSTRUCTION offset %r5, -20 222 frame-setup CFI_INSTRUCTION offset %r4, -24 223 DBG_VALUE debug-use %r0, debug-use _, !13, !20, debug-location !21 224 %r4 = MOVr killed %r0, 14, _, _ 225 DBG_VALUE debug-use %r4, debug-use _, !13, !20, debug-location !21 226 %r0 = MOVi 10, 14, _, _, debug-location !22 227 %r1 = MOVi 11, 14, _, _, debug-location !22 228 BL @func2, csr_aapcs, implicit-def dead %lr, implicit %sp, implicit killed %r0, implicit killed %r1, implicit-def %sp, implicit-def %r0, debug-location !22 229 %r5 = MOVr killed %r0, 14, _, _, debug-location !22 230 DBG_VALUE debug-use %r5, debug-use _, !14, !20, debug-location !23 231 CMPri %r4, 0, 14, _, implicit-def %cpsr, debug-location !25 232 Bcc %bb.5.if.end, 0, killed %cpsr 233 234 bb.1.if.then: 235 successors: %bb.3.for.cond 236 liveins: %r4, %r5 237 238 %r0 = MOVi 12, 14, _, _, debug-location !26 239 %r1 = MOVi 13, 14, _, _, debug-location !26 240 BL @func2, csr_aapcs, implicit-def dead %lr, implicit %sp, implicit killed %r0, implicit killed %r1, implicit-def %sp, implicit-def %r0, debug-location !26 241 %r6 = MOVr killed %r0, 14, _, _, debug-location !26 242 DBG_VALUE debug-use %r6, debug-use _, !15, !20, debug-location !27 243 %r7 = MOVi 1, 14, _, _ 244 DBG_VALUE 1, 0, !18, !20, debug-location !28 245 B %bb.3.for.cond 246 247 bb.2.for.body: 248 successors: %bb.3.for.cond 249 liveins: %r4, %r5, %r6, %r7 250 251 %r1 = ADDrr %r5, %r7, 14, _, _, debug-location !36 252 %r0 = MOVr %r7, 14, _, _, debug-location !36 253 BL @func2, csr_aapcs, implicit-def dead %lr, implicit %sp, implicit killed %r0, implicit killed %r1, implicit-def %sp, implicit-def dead %r0, debug-location !36 254 %r7 = ADDri killed %r7, 1, 14, _, _, debug-location !38 255 DBG_VALUE debug-use %r7, debug-use _, !18, !20, debug-location !28 256 257 bb.3.for.cond: 258 successors: %bb.2.for.body, %bb.4.for.cond.cleanup 259 liveins: %r4, %r5, %r6, %r7 260 261 DBG_VALUE debug-use %r7, debug-use _, !18, !20, debug-location !28 262 CMPrr %r7, %r4, 14, _, implicit-def %cpsr, debug-location !33 263 Bcc %bb.2.for.body, 11, killed %cpsr, debug-location !33 264 265 bb.4.for.cond.cleanup: 266 successors: %bb.5.if.end 267 liveins: %r4, %r5, %r6 268 269 %r0 = MOVr %r5, 14, _, _, debug-location !34 270 %r1 = MOVr killed %r6, 14, _, _, debug-location !34 271 BL @func2, csr_aapcs, implicit-def dead %lr, implicit %sp, implicit killed %r0, implicit killed %r1, implicit-def %sp, implicit-def dead %r0, debug-location !34 272 273 bb.5.if.end: 274 liveins: %r4, %r5 275 276 %r0 = MOVr killed %r5, 14, _, _, debug-location !43 277 %r1 = MOVr killed %r4, 14, _, _, debug-location !43 278 %sp = LDMIA_UPD %sp, 14, _, def %r4, def %r5, def %r6, def %r7, def %r11, def %lr, debug-location !43 279 TAILJMPd @func2, implicit %sp, implicit %sp, implicit killed %r0, implicit killed %r1, debug-location !43 280 281... 282