1 ; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 ; RUN: llc -mtriple=x86_64-linux -stop-after=early-tailduplication \
3 ; RUN: -verify-machineinstrs < %s | FileCheck %s
5 ; Ensure that we don't duplicate a block with an "INLINEASM_BR" instruction
7 declare dso_local void @foo()
9 define ptr @test1(ptr %arg1, ptr %arg2) {
10 ; CHECK-LABEL: name: test1
12 ; CHECK-NEXT: successors: %bb.1(0x50000000), %bb.2(0x30000000)
13 ; CHECK-NEXT: liveins: $rdi, $rsi
15 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gr64 = COPY $rsi
16 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gr64 = COPY $rdi
17 ; CHECK-NEXT: [[MOV64rm:%[0-9]+]]:gr64 = MOV64rm [[COPY1]], 1, $noreg, 0, $noreg :: (load (s64) from %ir.arg1)
18 ; CHECK-NEXT: [[SUB64rr:%[0-9]+]]:gr64 = SUB64rr [[MOV64rm]], [[COPY]], implicit-def $eflags
19 ; CHECK-NEXT: JCC_1 %bb.2, 4, implicit $eflags
20 ; CHECK-NEXT: JMP_1 %bb.1
22 ; CHECK-NEXT: bb.1.bb100:
23 ; CHECK-NEXT: successors: %bb.3(0x80000000)
25 ; CHECK-NEXT: MOV64mi32 [[COPY1]], 1, $noreg, 0, $noreg, 0 :: (store (s64) into %ir.arg1)
26 ; CHECK-NEXT: JMP_1 %bb.3
28 ; CHECK-NEXT: bb.2.bb106:
29 ; CHECK-NEXT: successors: %bb.3(0x80000000)
31 ; CHECK-NEXT: ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
32 ; CHECK-NEXT: CALL64pcrel32 @foo, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp
33 ; CHECK-NEXT: ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
35 ; CHECK-NEXT: bb.3.bb110:
36 ; CHECK-NEXT: successors: %bb.5(0x80000000), %bb.4(0x00000000)
38 ; CHECK-NEXT: [[PHI:%[0-9]+]]:gr64 = PHI [[COPY]], %bb.2, [[MOV64rm]], %bb.1
39 ; CHECK-NEXT: INLINEASM_BR &"#$0 $1 $2", 9 /* sideeffect mayload attdialect */, 13 /* imm */, 42, 13 /* imm */, 0, 13 /* imm */, %bb.4, 12 /* clobber */, implicit-def early-clobber $df, 12 /* clobber */, implicit-def early-clobber $fpsw, 12 /* clobber */, implicit-def early-clobber $eflags
40 ; CHECK-NEXT: JMP_1 %bb.5
42 ; CHECK-NEXT: bb.4.bb17.i.i.i (machine-block-address-taken, inlineasm-br-indirect-target):
43 ; CHECK-NEXT: successors: %bb.5(0x80000000)
46 ; CHECK-NEXT: bb.5.kmem_cache_has_cpu_partial.exit:
47 ; CHECK-NEXT: $rax = COPY [[PHI]]
48 ; CHECK-NEXT: RET 0, $rax
50 %i28.i = load ptr, ptr %arg1, align 8
51 %if = icmp ne ptr %i28.i, %arg2
52 br i1 %if, label %bb100, label %bb106
55 store ptr null, ptr %arg1, align 8
62 bb110: ; preds = %bb106, %bb100
63 %i10.1 = phi ptr [ %arg2, %bb106 ], [ %i28.i, %bb100 ]
64 callbr void asm sideeffect "#$0 $1 $2", "i,i,!i,~{dirflag},~{fpsr},~{flags}"(i32 42, i1 false)
65 to label %kmem_cache_has_cpu_partial.exit [label %bb17.i.i.i]
67 bb17.i.i.i: ; preds = %bb110
68 br label %kmem_cache_has_cpu_partial.exit
70 kmem_cache_has_cpu_partial.exit: ; preds = %bb110
74 ; The intent of this test is to test what happens when we have a callbr where
75 ; BOTH the fallthrough/direct target and the indirect target are the same basic
76 ; block. We might one day permit tail duplication here, but we need to ensure
77 ; that we don't crash or run afoul of any MachineVerifier checks.
78 define void @ceph_con_v2_try_read(i32 %__trans_tmp_3.sroa.0.0.copyload, i1 %tobool.not.i.i) nounwind {
79 ; CHECK-LABEL: name: ceph_con_v2_try_read
81 ; CHECK-NEXT: successors: %bb.1(0x80000000)
82 ; CHECK-NEXT: liveins: $edi, $esi
84 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gr32 = COPY $esi
85 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gr32 = COPY $edi
86 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gr8 = COPY [[COPY]].sub_8bit
88 ; CHECK-NEXT: bb.1.for.cond:
89 ; CHECK-NEXT: successors: %bb.2(0x30000000), %bb.1(0x50000000)
91 ; CHECK-NEXT: TEST32rr [[COPY1]], [[COPY1]], implicit-def $eflags
92 ; CHECK-NEXT: JCC_1 %bb.1, 5, implicit $eflags
93 ; CHECK-NEXT: JMP_1 %bb.2
95 ; CHECK-NEXT: bb.2.sw.bb:
96 ; CHECK-NEXT: successors: %bb.3(0x40000000), %bb.4(0x40000000)
98 ; CHECK-NEXT: ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
99 ; CHECK-NEXT: [[MOV32r0_:%[0-9]+]]:gr32 = MOV32r0 implicit-def dead $eflags
100 ; CHECK-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gr64 = SUBREG_TO_REG 0, killed [[MOV32r0_]], %subreg.sub_32bit
101 ; CHECK-NEXT: [[LEA64r:%[0-9]+]]:gr64 = LEA64r %stack.0.skip.i.i, 1, $noreg, 0, $noreg
102 ; CHECK-NEXT: $rdi = COPY [[LEA64r]]
103 ; CHECK-NEXT: CALL64r killed [[SUBREG_TO_REG]], csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp, implicit-def $eax
104 ; CHECK-NEXT: ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
105 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:gr32 = COPY $eax
106 ; CHECK-NEXT: TEST8ri [[COPY2]], 1, implicit-def $eflags
107 ; CHECK-NEXT: JCC_1 %bb.4, 4, implicit $eflags
108 ; CHECK-NEXT: JMP_1 %bb.3
110 ; CHECK-NEXT: bb.3.if.else.i.i:
111 ; CHECK-NEXT: successors: %bb.5(0x80000000)
113 ; CHECK-NEXT: INLINEASM_BR &"", 1 /* sideeffect attdialect */, 13 /* imm */, %bb.5
114 ; CHECK-NEXT: JMP_1 %bb.5
116 ; CHECK-NEXT: bb.4.process_message_header.exit.i:
117 ; CHECK-NEXT: successors: %bb.1(0x80000000)
119 ; CHECK-NEXT: LIFETIME_END %stack.0.skip.i.i
120 ; CHECK-NEXT: JMP_1 %bb.1
122 ; CHECK-NEXT: bb.5.if.end.i (machine-block-address-taken, inlineasm-br-indirect-target):
123 ; CHECK-NEXT: successors: %bb.1(0x80000000)
125 ; CHECK-NEXT: LIFETIME_END %stack.0.skip.i.i
126 ; CHECK-NEXT: JMP_1 %bb.1
128 %skip.i.i = alloca i32, i32 0, align 4
129 %cond = icmp eq i32 %__trans_tmp_3.sroa.0.0.copyload, 0
133 br i1 %cond, label %sw.bb, label %for.cond
136 %call.i.i2 = call i32 null(ptr %skip.i.i)
137 br i1 %tobool.not.i.i, label %if.else.i.i, label %process_message_header.exit.i
140 callbr void asm sideeffect "", "!i"()
141 to label %if.end.i [label %if.end.i]
143 process_message_header.exit.i:
144 call void @llvm.lifetime.end.p0(i64 0, ptr %skip.i.i)
148 call void @llvm.lifetime.end.p0(i64 0, ptr %skip.i.i)
152 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)