1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 4
2 # RUN: llc -mtriple=arm64-apple-macosx -mcpu=apple-m1 -verify-coalescing -run-pass=register-coalescer -o - %s | FileCheck %s
4 # Hits assert "Trying to add an operand to a machine instr that is
5 # already done!" when rematerializing during greedy. This was because
6 # an IMPLICIT_DEF ended up with some immediate operands during
7 # coalescing. A SUBREG_TO_REG was not dropping the immediate operands
8 # when mutating to IMPLICIT_DEF, and would later fail the assert when
9 # creating a new IMPLICIT_DEF copy during rematerialization.
12 define void @_ZN38SanitizerCommonInterceptors_Scanf_Test8TestBodyEv() {
16 declare void @_ZL9testScanfPKcjz(ptr, i32, ...)
20 name: _ZN38SanitizerCommonInterceptors_Scanf_Test8TestBodyEv
22 tracksRegLiveness: true
30 liveins: $x0, $x1, $x2, $x3, $x4, $x5, $x6
32 ; CHECK-LABEL: name: _ZN38SanitizerCommonInterceptors_Scanf_Test8TestBodyEv
33 ; CHECK: liveins: $x0, $x1, $x2, $x3, $x4, $x5, $x6
35 ; CHECK-NEXT: [[DEF:%[0-9]+]]:gpr64sp = IMPLICIT_DEF
36 ; CHECK-NEXT: dead [[DEF1:%[0-9]+]]:gpr32 = IMPLICIT_DEF
37 ; CHECK-NEXT: [[DEF2:%[0-9]+]]:gpr64common = IMPLICIT_DEF
38 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x5
39 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr64 = COPY $x4
40 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gpr64 = COPY $x3
41 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:gpr64 = COPY $x2
42 ; CHECK-NEXT: [[COPY4:%[0-9]+]]:gpr64 = COPY $x1
43 ; CHECK-NEXT: [[COPY5:%[0-9]+]]:gpr64 = COPY $x0
44 ; CHECK-NEXT: [[DEF3:%[0-9]+]]:gpr64 = IMPLICIT_DEF
45 ; CHECK-NEXT: [[DEF4:%[0-9]+]]:gpr64 = IMPLICIT_DEF
46 ; CHECK-NEXT: [[DEF5:%[0-9]+]]:gpr64 = IMPLICIT_DEF
47 ; CHECK-NEXT: ADJCALLSTACKDOWN 16, 0, implicit-def dead $sp, implicit $sp
48 ; CHECK-NEXT: BL @_ZL9testScanfPKcjz, csr_darwin_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp
49 ; CHECK-NEXT: ADJCALLSTACKUP 16, 0, implicit-def dead $sp, implicit $sp
50 ; CHECK-NEXT: ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp
51 ; CHECK-NEXT: STRXui [[DEF3]], [[DEF]], 0 :: (store (s64) into stack)
52 ; CHECK-NEXT: ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp
53 ; CHECK-NEXT: STRWui undef [[DEF1]], [[DEF2]], 0 :: (store (s32))
54 ; CHECK-NEXT: ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp
55 ; CHECK-NEXT: STRXui [[DEF4]], undef [[DEF]], 0 :: (store (s64) into stack)
56 ; CHECK-NEXT: $x0 = COPY [[COPY5]]
57 ; CHECK-NEXT: ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp
58 ; CHECK-NEXT: ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp
59 ; CHECK-NEXT: $x0 = COPY [[COPY4]]
60 ; CHECK-NEXT: ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp
61 ; CHECK-NEXT: ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp
62 ; CHECK-NEXT: $x0 = COPY [[COPY3]]
63 ; CHECK-NEXT: ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp
64 ; CHECK-NEXT: ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp
65 ; CHECK-NEXT: $x0 = COPY [[COPY2]]
66 ; CHECK-NEXT: ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp
67 ; CHECK-NEXT: ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp
68 ; CHECK-NEXT: $x0 = COPY [[COPY1]]
69 ; CHECK-NEXT: ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp
70 ; CHECK-NEXT: ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp
71 ; CHECK-NEXT: $x0 = COPY [[COPY]]
72 ; CHECK-NEXT: ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp
73 ; CHECK-NEXT: ADJCALLSTACKDOWN 24, 0, implicit-def dead $sp, implicit $sp
74 ; CHECK-NEXT: STRXui [[DEF5]], undef [[DEF]], 1 :: (store (s64) into stack + 8)
75 ; CHECK-NEXT: ADJCALLSTACKUP 24, 0, implicit-def dead $sp, implicit $sp
76 ; CHECK-NEXT: RET_ReallyLR
77 %0:gpr64sp = IMPLICIT_DEF
78 %1:gpr32 = IMPLICIT_DEF
79 %2:gpr64common = IMPLICIT_DEF
80 %3:gpr64 = COPY killed $x5
81 %4:gpr64 = COPY killed $x4
82 %5:gpr64 = COPY killed $x3
83 %6:gpr64 = COPY killed $x2
84 %7:gpr64 = COPY killed $x1
85 %8:gpr64 = COPY killed $x0
86 %9:gpr64 = IMPLICIT_DEF
87 %10:gpr64 = IMPLICIT_DEF
88 %11:gpr64 = SUBREG_TO_REG 0, killed undef %1, %subreg.sub_32
89 ADJCALLSTACKDOWN 16, 0, implicit-def dead $sp, implicit $sp
90 BL @_ZL9testScanfPKcjz, csr_darwin_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp
91 ADJCALLSTACKUP 16, 0, implicit-def dead $sp, implicit $sp
92 ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp
93 STRXui %9, killed %0, 0 :: (store (s64) into stack)
94 ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp
95 STRWui undef %1, killed %2, 0 :: (store (s32))
96 ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp
97 STRXui killed %10, killed undef %0, 0 :: (store (s64) into stack)
99 ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp
100 ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp
102 ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp
103 ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp
105 ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp
106 ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp
108 ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp
109 ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp
111 ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp
112 ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp
114 ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp
115 ADJCALLSTACKDOWN 24, 0, implicit-def dead $sp, implicit $sp
116 STRXui killed %11, undef %0, 1 :: (store (s64) into stack + 8)
117 ADJCALLSTACKUP 24, 0, implicit-def dead $sp, implicit $sp