1 # RUN: llc -run-pass=branch-folder %s -o - | FileCheck %s
5 # Don't form conditional tail calls when the original conditional branch has
6 # the same true and false destination. Otherwise, when we remove the tail call
7 # successor we will also remove the fallthrough successor from the CFG.
11 # CHECK: successors: %bb.1(0x40000000)
12 # CHECK: liveins: $edi
13 # CHECK: CMP32ri8 killed $edi, 2, implicit-def $eflags
14 # CHECK: TCRETURNdi64cc @mergeable_conditional_tailcall
16 # This was the unconditional branch to a dead MBB that we left behind before
18 # CHECK-NOT: JMP_1 %bb.-1
22 source_filename = "t.ll"
23 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
24 target triple = "x86_64--linux"
26 @static_local_guard = external global i64, align 8
28 ; Function Attrs: optsize
29 define void @f(i32 %arg) #0 {
31 switch i32 %arg, label %sw.epilog [
37 sw.bb: ; preds = %entry, %entry
38 %tmp = load atomic i8, i8* bitcast (i64* @static_local_guard to i8*) acquire, align 8
39 %guard.uninitialized.i = icmp eq i8 %tmp, 0
40 br i1 %guard.uninitialized.i, label %init.check.i, label %return, !prof !0
42 init.check.i: ; preds = %sw.bb
43 tail call void @initialize_static_local(i64* nonnull @static_local_guard)
46 sw.bb2: ; preds = %entry
47 tail call void @mergeable_conditional_tailcall()
50 sw.epilog: ; preds = %entry
51 tail call void @mergeable_conditional_tailcall()
54 return: ; preds = %sw.bb
58 declare void @mergeable_conditional_tailcall()
60 declare void @initialize_static_local(i64*)
62 ; Function Attrs: nounwind
63 declare void @llvm.stackprotector(i8*, i8**) #1
65 attributes #0 = { optsize }
66 attributes #1 = { nounwind }
68 !0 = !{!"branch_weights", i32 1, i32 1048575}
74 exposesReturnsTwice: false
76 regBankSelected: false
78 tracksRegLiveness: true
81 - { reg: '$edi', virtual-reg: '' }
83 isFrameAddressTaken: false
84 isReturnAddressTaken: false
94 hasOpaqueSPAdjustment: false
96 hasMustTailInVarArgFunc: false
104 successors: %bb.2(0x40000000), %bb.1(0x40000000)
107 CMP32ri8 killed $edi, 2, implicit-def $eflags
108 JCC_1 %bb.2, 2, implicit $eflags
112 successors: %bb.4(0x40000000), %bb.5(0x40000000)
115 JCC_1 %bb.4, 4, implicit killed $eflags
119 successors: %bb.3(0x00000800), %bb.6(0x7ffff800)
121 $al = MOV8rm $rip, 1, $noreg, @static_local_guard, $noreg :: (volatile load acquire (s8) from `i8* bitcast (i64* @static_local_guard to i8*)`, align 8)
122 TEST8rr killed $al, $al, implicit-def $eflags
123 JCC_1 %bb.6, 5, implicit killed $eflags
127 dead $edi = MOV32ri @static_local_guard, implicit-def $rdi
128 TCRETURNdi64 @initialize_static_local, 0, csr_64, implicit $rsp, implicit $rdi
131 TCRETURNdi64 @mergeable_conditional_tailcall, 0, csr_64, implicit $rsp
134 TCRETURNdi64 @mergeable_conditional_tailcall, 0, csr_64, implicit $rsp