1# RUN: sed 's_;AAAAAA __' < %s \ 2# RUN: | llc -x mir -o - -start-before=phi-node-elimination \ 3# RUN: -stop-after=stack-slot-coloring -simplify-mir \ 4# RUN: -experimental-debug-variable-locations=true \ 5# RUN: | FileCheck %s --check-prefix=DBGPHIS 6# RUN: sed 's_;BBBBBB __' < %s \ 7# RUN: | llc -x mir -o - -start-before=phi-node-elimination \ 8# RUN: -stop-after=stack-slot-coloring -simplify-mir \ 9# RUN: -experimental-debug-variable-locations=false \ 10# RUN: | FileCheck %s --check-prefix=DBGVALS 11# 12# Test that DBG_PHI instructions do not add "weight" to stack slots and cause 13# their coalescing / coloring to change. This is hard to trigger, because it's 14# closely coupled with the register allocator. Thus, the test is very 15# complicated and hard to reduce. 16# 17# In block 13 there are two implementations of variable location tracking, but 18# both are commented out. Use sed in the command lines above to un-comment 19# each one and test what it does: in each case, the PHI should occur in 20# %stack.4 rather than anywhere else. 21# 22# Future register allocator changes might change the slot; in that case, just 23# update the slot number, so long as it's the same between each RUN. 24# 25# DBGPHIS: DBG_PHI %stack.4, 26# DBGVALS: DBG_VALUE %stack.4, 27 28--- | 29 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 30 target triple = "x86_64-unknown-linux-gnu" 31 32 define hidden fastcc i64 @amd64_push_arguments(i32 *%regcache, i32 *%args) unnamed_addr !dbg !4 { 33 ret i64 0 34 } 35 36 ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn 37 declare void @llvm.dbg.value(metadata, metadata, metadata) 38 39 !llvm.module.flags = !{!0, !1} 40 !llvm.dbg.cu = !{!2} 41 42 !0 = !{i32 2, !"Debug Info Version", i32 3} 43 !1 = !{i32 2, !"Dwarf Version", i32 4} 44 !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "beards", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) 45 !3 = !DIFile(filename: "bees.cpp", directory: ".") 46 !4 = distinct !DISubprogram(name: "nope", scope: !3, file: !3, line: 1, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !8) 47 !5 = !DISubroutineType(types: !6) 48 !6 = !{!7} 49 !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 50 !8 = !{} 51 !9 = !DILocation(line: 0, scope: !4) 52 !10 = !DILocalVariable(name: "flannel", scope: !4, file: !3, line: 1, type: !7) 53... 54--- 55name: amd64_push_arguments 56alignment: 16 57tracksRegLiveness: true 58registers: 59 - { id: 0, class: gr32 } 60 - { id: 1, class: gr32 } 61 - { id: 2, class: gr32 } 62 - { id: 3, class: gr64 } 63 - { id: 4, class: gr32 } 64 - { id: 5, class: gr32 } 65 - { id: 6, class: gr32 } 66 - { id: 7, class: gr32 } 67 - { id: 8, class: gr64 } 68 - { id: 9, class: gr32 } 69 - { id: 10, class: gr32 } 70 - { id: 11, class: gr64 } 71 - { id: 12, class: gr32 } 72 - { id: 13, class: gr64 } 73 - { id: 14, class: gr32 } 74 - { id: 15, class: gr64 } 75 - { id: 16, class: gr64 } 76 - { id: 17, class: gr64 } 77 - { id: 18, class: gr32 } 78 - { id: 19, class: gr8 } 79 - { id: 20, class: gr64 } 80 - { id: 21, class: gr32 } 81 - { id: 22, class: gr32 } 82 - { id: 23, class: gr8 } 83 - { id: 24, class: gr32 } 84 - { id: 25, class: gr32 } 85 - { id: 26, class: gr32 } 86 - { id: 27, class: gr32 } 87 - { id: 28, class: gr8 } 88 - { id: 29, class: gr32 } 89 - { id: 30, class: gr8 } 90 - { id: 31, class: gr32 } 91 - { id: 32, class: gr32 } 92 - { id: 33, class: gr32 } 93 - { id: 34, class: gr8 } 94 - { id: 35, class: gr32 } 95 - { id: 36, class: gr64 } 96 - { id: 37, class: gr32 } 97 - { id: 38, class: gr32 } 98 - { id: 39, class: gr8 } 99 - { id: 40, class: gr32 } 100 - { id: 41, class: gr8 } 101 - { id: 42, class: gr32 } 102 - { id: 43, class: gr32 } 103 - { id: 44, class: gr64_nosp } 104 - { id: 45, class: gr64 } 105 - { id: 46, class: gr32 } 106 - { id: 47, class: gr64 } 107 - { id: 48, class: gr32 } 108 - { id: 49, class: gr32 } 109 - { id: 50, class: gr64 } 110 - { id: 51, class: gr64 } 111 - { id: 52, class: gr64 } 112 - { id: 53, class: gr64 } 113 - { id: 54, class: gr32 } 114 - { id: 55, class: gr64 } 115 - { id: 56, class: gr32 } 116liveins: 117 - { reg: '$rdi', virtual-reg: '%15' } 118frameInfo: 119 maxAlignment: 8 120 hasCalls: true 121stack: 122 - { id: 0, size: 8, alignment: 8 } 123 - { id: 1, type: variable-sized, alignment: 1 } 124machineFunctionInfo: {} 125body: | 126 bb.0: 127 successors: %bb.2(0x00000800), %bb.1(0x7ffff800) 128 liveins: $rdi 129 130 %15:gr64 = COPY killed $rdi 131 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !9 132 ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !9 133 %18:gr32 = MOV32r0 implicit-def dead $eflags 134 %19:gr8 = COPY killed %18.sub_8bit 135 TEST8rr killed %19, %19, implicit-def $eflags, debug-location !9 136 JCC_1 %bb.2, 5, implicit killed $eflags, debug-location !9 137 JMP_1 %bb.1, debug-location !9 138 139 bb.1: 140 RET 0, undef $rax 141 142 bb.2: 143 %27:gr32 = MOV32r0 implicit-def dead $eflags 144 %50:gr64 = LEA64r %stack.0, 1, $noreg, 0, $noreg 145 %54:gr32 = MOV32ri 8 146 147 bb.3: 148 successors: %bb.4, %bb.5 149 150 %0:gr32 = PHI undef %21:gr32, %bb.2, %0, %bb.5, %0, %bb.6, %0, %bb.8, %0, %bb.10, %10, %bb.21 151 %23:gr8 = COPY %27.sub_8bit 152 TEST8rr killed %23, %23, implicit-def $eflags, debug-location !9 153 JCC_1 %bb.5, 5, implicit killed $eflags, debug-location !9 154 JMP_1 %bb.4, debug-location !9 155 156 bb.4: 157 %24:gr32 = MOV32ri 1 158 159 bb.5: 160 successors: %bb.3(0x20000000), %bb.6(0x60000000) 161 162 %1:gr32 = PHI %27, %bb.3, %24, %bb.4, debug-location !9 163 %25:gr32 = nsw ADD32rr %1, %0, implicit-def dead $eflags, debug-location !9 164 CMP32ri8 killed %25, 6, implicit-def $eflags, debug-location !9 165 JCC_1 %bb.3, 7, implicit killed $eflags, debug-location !9 166 JMP_1 %bb.6, debug-location !9 167 168 bb.6: 169 successors: %bb.3(0x2aaaaaab), %bb.7(0x55555555) 170 171 %28:gr8 = COPY %27.sub_8bit 172 TEST8rr killed %28, %28, implicit-def $eflags, debug-location !9 173 JCC_1 %bb.3, 5, implicit killed $eflags, debug-location !9 174 JMP_1 %bb.7, debug-location !9 175 176 bb.7: 177 successors: %bb.8(0x60000000), %bb.9(0x20000000) 178 179 TEST32rr killed %1, %1, implicit-def $eflags, debug-location !9 180 JCC_1 %bb.9, 5, implicit killed $eflags, debug-location !9 181 JMP_1 %bb.8, debug-location !9 182 183 bb.8: 184 successors: %bb.3(0x55555555), %bb.9(0x2aaaaaab) 185 186 %30:gr8 = COPY %27.sub_8bit 187 TEST8rr killed %30, %30, implicit-def $eflags, debug-location !9 188 JCC_1 %bb.3, 5, implicit killed $eflags, debug-location !9 189 JMP_1 %bb.9, debug-location !9 190 191 bb.9: 192 successors: %bb.10(0x80000000), %bb.12(0x00000000) 193 194 CMP32ri8 undef %32:gr32, 16, implicit-def $eflags, debug-location !9 195 JCC_1 %bb.12, 15, implicit killed $eflags, debug-location !9 196 JMP_1 %bb.10, debug-location !9 197 198 bb.10: 199 successors: %bb.11, %bb.3 200 201 %34:gr8 = COPY %27.sub_8bit 202 TEST8rr killed %34, %34, implicit-def $eflags, debug-location !9 203 JCC_1 %bb.3, 5, implicit killed $eflags, debug-location !9 204 JMP_1 %bb.11, debug-location !9 205 206 bb.11: 207 %36:gr64 = SUBREG_TO_REG 0, %27, %subreg.sub_32bit 208 JMP_1 %bb.13, debug-location !9 209 210 bb.12: 211 successors: 212 213 214 bb.13: 215 successors: %bb.18(0x2aaaaaab), %bb.14(0x55555555) 216 217 %2:gr32 = PHI undef %35:gr32, %bb.11, %14, %bb.21 218 %3:gr64 = PHI %36, %bb.11, %13, %bb.21 219 ;AAAAAA %4:gr32 = PHI %0, %bb.11, %10, %bb.21, debug-instr-number 1 220 ;BBBBBB %4:gr32 = PHI %0, %bb.11, %10, %bb.21 221 %5:gr32 = PHI undef %35:gr32, %bb.11, %9, %bb.21 222 ;AAAAAA DBG_INSTR_REF 1, 0, !10, !DIExpression(), debug-location !9 223 ;BBBBBB DBG_VALUE %4, 0, !10, !DIExpression(), debug-location !9 224 %39:gr8 = COPY %27.sub_8bit 225 TEST8rr killed %39, %39, implicit-def $eflags, debug-location !9 226 JCC_1 %bb.18, 5, implicit killed $eflags, debug-location !9 227 JMP_1 %bb.14, debug-location !9 228 229 bb.14: 230 successors: %bb.17(0x40000001), %bb.15(0x3fffffff) 231 232 %41:gr8 = COPY %27.sub_8bit 233 TEST8rr killed %41, %41, implicit-def $eflags, debug-location !9 234 JCC_1 %bb.17, 5, implicit killed $eflags, debug-location !9 235 JMP_1 %bb.15, debug-location !9 236 237 bb.15: 238 239 bb.16: 240 %6:gr32 = nsw INC32r killed %4, implicit-def dead $eflags, debug-location !9 241 %48:gr32 = MOV32r0 implicit-def dead $eflags 242 JMP_1 %bb.21, debug-location !9 243 244 bb.17: 245 %7:gr32 = nsw INC32r killed %5, implicit-def dead $eflags, debug-location !9 246 %46:gr32 = MOV32r0 implicit-def dead $eflags 247 JMP_1 %bb.21, debug-location !9 248 249 bb.18: 250 successors: %bb.20(0x80000000), %bb.19(0x00000000) 251 252 TEST32rr %5, %5, implicit-def $eflags, debug-location !9 253 JCC_1 %bb.20, 15, implicit killed $eflags, debug-location !9 254 JMP_1 %bb.19, debug-location !9 255 256 bb.19: 257 successors: 258 259 260 bb.20: 261 %43:gr32 = nsw DEC32r %5, implicit-def dead $eflags, debug-location !9 262 %44:gr64_nosp = SUBREG_TO_REG 0, killed %43, %subreg.sub_32bit 263 ; Fiddled with to morph into llvm test, 264 %8:gr64 = LEA64r $noreg, 4, killed %44, @amd64_push_arguments, $noreg, debug-location !9 265 %42:gr32 = MOV32ri 8 266 JMP_1 %bb.21, debug-location !9 267 268 bb.21: 269 successors: %bb.13(0x7c000000), %bb.3(0x04000000) 270 271 %9:gr32 = PHI %5, %bb.20, %7, %bb.17, %5, %bb.16, debug-location !9 272 %10:gr32 = PHI %4, %bb.20, %4, %bb.17, %6, %bb.16, debug-location !9 273 %11:gr64 = PHI %8, %bb.20, undef %45:gr64, %bb.17, undef %47:gr64, %bb.16 274 %12:gr32 = PHI %42, %bb.20, %46, %bb.17, %48, %bb.16, debug-location !9 275 %49:gr32 = MOV32rm killed %11, 1, $noreg, 0, $noreg, debug-location !9 :: (load (s32) from `i32 *undef`) 276 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !9 277 $rdi = COPY %50, debug-location !9 278 CALL64pcrel32 target-flags(x86-plt) &memcpy, csr_64, implicit $rsp, implicit $ssp, implicit killed $rdi, implicit undef $rsi, implicit undef $rdx, implicit-def $rsp, implicit-def $ssp, implicit-def dead $rax, debug-location !9 279 ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !9 280 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !9 281 $rdi = COPY %15, debug-location !9 282 $esi = COPY killed %49, debug-location !9 283 $edx = COPY killed %12, debug-location !9 284 $ecx = COPY %54, debug-location !9 285 $r8 = COPY %50, debug-location !9 286 CALL64r undef %55:gr64, csr_64, implicit $rsp, implicit $ssp, implicit killed $rdi, implicit killed $esi, implicit killed $edx, implicit killed $ecx, implicit killed $r8, implicit-def $rsp, implicit-def $ssp, debug-location !9 287 ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !9 288 %13:gr64 = nuw nsw INC64r killed %3, implicit-def dead $eflags, debug-location !9 289 %14:gr32 = ADD32ri8 killed %2, -8, implicit-def dead $eflags, debug-location !9 290 CMP32ri8 %14, 8, implicit-def $eflags, debug-location !9 291 JCC_1 %bb.13, 15, implicit killed $eflags, debug-location !9 292 JMP_1 %bb.3, debug-location !9 293 294... 295