1 ; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
2 ; RUN: llc -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -stop-after=x86-optimize-LEAs -experimental-debug-variable-locations=false < %s \
3 ; RUN: | FileCheck %s --check-prefix=NORMAL
4 ; RUN: llc -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -stop-after=x86-optimize-LEAs -experimental-debug-variable-locations < %s \
5 ; RUN: | FileCheck %s --check-prefix=INSTRREF
7 ; The LEA optimization pass used to crash on this testcase.
9 ; This test case used to trigger:
11 ; assert(MRI->use_empty(LastVReg) &&
12 ; "The LEA's def register must have no uses");
14 target triple = "x86_64-unknown-linux-gnu"
16 %t10 = type { ptr, [32 x i8] }
19 ; NORMAL-LABEL: name: foo
20 ; NORMAL: bb.0.bb_entry:
21 ; NORMAL-NEXT: successors: %bb.1(0x80000000)
23 ; NORMAL-NEXT: [[MOV32r0_:%[0-9]+]]:gr32 = MOV32r0 implicit-def dead $eflags
24 ; NORMAL-NEXT: [[COPY:%[0-9]+]]:gr8 = COPY [[MOV32r0_]].sub_8bit
25 ; NORMAL-NEXT: [[LEA64r:%[0-9]+]]:gr64 = LEA64r %stack.1.i, 1, $noreg, 0, $noreg
26 ; NORMAL-NEXT: [[DEF:%[0-9]+]]:gr64 = IMPLICIT_DEF
28 ; NORMAL-NEXT: bb.1.bb_8:
29 ; NORMAL-NEXT: successors: %bb.3(0x40000000), %bb.2(0x40000000)
31 ; NORMAL-NEXT: TEST8rr [[COPY]], [[COPY]], implicit-def $eflags
32 ; NORMAL-NEXT: JCC_1 %bb.3, 5, implicit $eflags
33 ; NORMAL-NEXT: JMP_1 %bb.2
35 ; NORMAL-NEXT: bb.2.bb_mid:
36 ; NORMAL-NEXT: successors: %bb.3(0x80000000)
38 ; NORMAL-NEXT: [[MOVUPSrm:%[0-9]+]]:vr128 = MOVUPSrm %stack.1.i, 1, $noreg, 40, $noreg :: (load (s128) from %ir.i4, align 8)
39 ; NORMAL-NEXT: MOVUPSmr $noreg, 1, $noreg, 0, $noreg, killed [[MOVUPSrm]] :: (store (s128) into `ptr null`, align 8)
40 ; NORMAL-NEXT: DBG_VALUE_LIST !3, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_plus_uconst, 40, DW_OP_stack_value), %stack.1.i, %stack.1.i, debug-location !8
41 ; NORMAL-NEXT: [[MOVUPSrm1:%[0-9]+]]:vr128 = MOVUPSrm %stack.1.i, 1, $noreg, 40, $noreg :: (load (s128) from %ir.i6, align 8)
42 ; NORMAL-NEXT: MOVUPSmr $noreg, 1, $noreg, 0, $noreg, killed [[MOVUPSrm1]] :: (store (s128) into `ptr null`, align 8)
44 ; NORMAL-NEXT: bb.3.bb_last:
45 ; NORMAL-NEXT: successors: %bb.1(0x80000000)
47 ; NORMAL-NEXT: ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
48 ; NORMAL-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gr64 = SUBREG_TO_REG 0, [[MOV32r0_]], %subreg.sub_32bit
49 ; NORMAL-NEXT: $rdi = COPY [[SUBREG_TO_REG]]
50 ; NORMAL-NEXT: $rsi = COPY [[SUBREG_TO_REG]]
51 ; NORMAL-NEXT: $rdx = COPY [[SUBREG_TO_REG]]
52 ; NORMAL-NEXT: $ecx = COPY [[MOV32r0_]]
53 ; NORMAL-NEXT: $r8 = COPY [[LEA64r]]
54 ; NORMAL-NEXT: CALL64r [[DEF]], csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit $rsi, implicit $rdx, implicit $ecx, implicit $r8, implicit-def $rsp, implicit-def $ssp
55 ; NORMAL-NEXT: ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
56 ; NORMAL-NEXT: JMP_1 %bb.1
58 ; INSTRREF-LABEL: name: foo
59 ; INSTRREF: bb.0.bb_entry:
60 ; INSTRREF-NEXT: successors: %bb.1(0x80000000)
61 ; INSTRREF-NEXT: {{ $}}
62 ; INSTRREF-NEXT: [[MOV32r0_:%[0-9]+]]:gr32 = MOV32r0 implicit-def dead $eflags
63 ; INSTRREF-NEXT: [[COPY:%[0-9]+]]:gr8 = COPY [[MOV32r0_]].sub_8bit
64 ; INSTRREF-NEXT: [[LEA64r:%[0-9]+]]:gr64 = LEA64r %stack.1.i, 1, $noreg, 0, $noreg
65 ; INSTRREF-NEXT: [[DEF:%[0-9]+]]:gr64 = IMPLICIT_DEF
66 ; INSTRREF-NEXT: {{ $}}
67 ; INSTRREF-NEXT: bb.1.bb_8:
68 ; INSTRREF-NEXT: successors: %bb.3(0x40000000), %bb.2(0x40000000)
69 ; INSTRREF-NEXT: {{ $}}
70 ; INSTRREF-NEXT: TEST8rr [[COPY]], [[COPY]], implicit-def $eflags
71 ; INSTRREF-NEXT: JCC_1 %bb.3, 5, implicit $eflags
72 ; INSTRREF-NEXT: JMP_1 %bb.2
73 ; INSTRREF-NEXT: {{ $}}
74 ; INSTRREF-NEXT: bb.2.bb_mid:
75 ; INSTRREF-NEXT: successors: %bb.3(0x80000000)
76 ; INSTRREF-NEXT: {{ $}}
77 ; INSTRREF-NEXT: [[MOVUPSrm:%[0-9]+]]:vr128 = MOVUPSrm %stack.1.i, 1, $noreg, 40, $noreg :: (load (s128) from %ir.i4, align 8)
78 ; INSTRREF-NEXT: MOVUPSmr $noreg, 1, $noreg, 0, $noreg, killed [[MOVUPSrm]] :: (store (s128) into `ptr null`, align 8)
79 ; INSTRREF-NEXT: DBG_VALUE_LIST !3, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_plus_uconst, 40, DW_OP_stack_value), %stack.1.i, %stack.1.i, debug-location !8
80 ; INSTRREF-NEXT: [[MOVUPSrm1:%[0-9]+]]:vr128 = MOVUPSrm %stack.1.i, 1, $noreg, 40, $noreg :: (load (s128) from %ir.i6, align 8)
81 ; INSTRREF-NEXT: MOVUPSmr $noreg, 1, $noreg, 0, $noreg, killed [[MOVUPSrm1]] :: (store (s128) into `ptr null`, align 8)
82 ; INSTRREF-NEXT: {{ $}}
83 ; INSTRREF-NEXT: bb.3.bb_last:
84 ; INSTRREF-NEXT: successors: %bb.1(0x80000000)
85 ; INSTRREF-NEXT: {{ $}}
86 ; INSTRREF-NEXT: ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
87 ; INSTRREF-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gr64 = SUBREG_TO_REG 0, [[MOV32r0_]], %subreg.sub_32bit
88 ; INSTRREF-NEXT: $rdi = COPY [[SUBREG_TO_REG]]
89 ; INSTRREF-NEXT: $rsi = COPY [[SUBREG_TO_REG]]
90 ; INSTRREF-NEXT: $rdx = COPY [[SUBREG_TO_REG]]
91 ; INSTRREF-NEXT: $ecx = COPY [[MOV32r0_]]
92 ; INSTRREF-NEXT: $r8 = COPY [[LEA64r]]
93 ; INSTRREF-NEXT: CALL64r [[DEF]], csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit $rsi, implicit $rdx, implicit $ecx, implicit $r8, implicit-def $rsp, implicit-def $ssp
94 ; INSTRREF-NEXT: ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
95 ; INSTRREF-NEXT: JMP_1 %bb.1
97 %tmp11 = alloca [0 x [0 x i32]], i32 0, align 4
98 %i = alloca %t10, align 8
99 %i1 = alloca %t10, align 8
102 bb_8: ; preds = %bb_last, %bb_entry
103 br i1 undef, label %bb_last, label %bb_mid
105 bb_mid: ; preds = %bb_8
106 %i4 = getelementptr inbounds %t10, ptr %i1, i64 0, i32 1, i64 32
107 %i6 = getelementptr inbounds %t10, ptr %i, i64 0, i32 1, i64 32
108 call void @llvm.lifetime.start.p0(i64 0, ptr nonnull %i1)
109 %v21 = call i64 @llvm.ctlz.i64(i64 undef, i1 false)
110 call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull dereferenceable(16) null, ptr noundef nonnull align 8 dereferenceable(16) %i4, i64 16, i1 false)
111 call void @llvm.dbg.value(metadata !DIArgList(ptr %i4, ptr %i4), metadata !4, metadata !DIExpression(DW_OP_LLVM_arg, 0)), !dbg !9
112 call void @llvm.lifetime.end.p0(i64 0, ptr nonnull %i1)
113 call void @llvm.lifetime.start.p0(i64 0, ptr nonnull %i)
114 call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull dereferenceable(16) null, ptr noundef nonnull align 8 dereferenceable(16) %i6, i64 16, i1 false)
115 call void @llvm.lifetime.end.p0(i64 0, ptr nonnull %i)
118 bb_last: ; preds = %bb_mid, %bb_8
119 call void @llvm.lifetime.start.p0(i64 0, ptr nonnull %tmp11)
120 call void undef(ptr null, ptr null, ptr null, i32 0, ptr nonnull %tmp11)
121 call void @llvm.lifetime.end.p0(i64 0, ptr nonnull %tmp11)
125 declare i64 @llvm.ctlz.i64(i64, i1 immarg)
126 declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg)
127 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)
128 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)
129 declare void @llvm.dbg.value(metadata, metadata, metadata)
132 !llvm.module.flags = !{!2}
134 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug)
135 !1 = !DIFile(filename: "n", directory: "/proc/self/cwd", checksumkind: CSK_MD5, checksum: "e588179fedd8fcdfada963f2434cb950")
136 !2 = !{i32 2, !"Debug Info Version", i32 3}
137 !3 = !{!"function_entry_count", i64 2423}
138 !4 = !DILocalVariable(name: "r", scope: !5, file: !6, line: 93)
139 !5 = distinct !DISubprogram(name: "c", scope: !7, file: !6, line: 92, spFlags: DISPFlagDefinition, unit: !0)
140 !6 = !DIFile(filename: "a", directory: "/proc/self/cwd")
141 !7 = !DINamespace(name: "u", scope: !8)
142 !8 = !DINamespace(name: "s", scope: null)
143 !9 = !DILocation(line: 0, scope: !5)