1# RUN: llc -mtriple=x86_64-apple-macosx10.12.0 -O3 -run-pass=block-placement -o - %s | FileCheck %s
2
3--- |
4  ; ModuleID = 'test.ll'
5  source_filename = "test.ll"
6  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
7
8  declare void @stub(i32*)
9
10  define i32 @f(i32* %ptr, i1 %cond) {
11  entry:
12    br i1 %cond, label %left, label %right
13
14  left:                                             ; preds = %entry
15    %is_null = icmp eq i32* %ptr, null
16    br i1 %is_null, label %null, label %not_null, !prof !0, !make.implicit !1
17
18  not_null:                                         ; preds = %left
19    %val = load i32, i32* %ptr
20    ret i32 %val
21
22  null:                                             ; preds = %left
23    call void @stub(i32* %ptr)
24    unreachable
25
26  right:                                            ; preds = %entry
27    call void @stub(i32* null)
28    unreachable
29  }
30
31  ; Function Attrs: nounwind
32  declare void @llvm.stackprotector(i8*, i8**) #0
33
34  attributes #0 = { nounwind }
35
36  !0 = !{!"branch_weights", i32 1048575, i32 1}
37  !1 = !{}
38
39...
40---
41# CHECK: name:            f
42name:            f
43alignment:       4
44tracksRegLiveness: true
45liveins:
46  - { reg: '%rdi' }
47  - { reg: '%esi' }
48
49# CHECK: %eax = FAULTING_LOAD_OP %bb.3.null, 1684, killed %rdi, 1, _, 0, _ :: (load 4 from %ir.ptr)
50# CHECK-NEXT: JMP_1 %bb.2.not_null
51# CHECK: bb.3.null:
52# CHECK:  bb.4.right:
53# CHECK:  bb.2.not_null:
54
55body:             |
56  bb.0.entry:
57    successors: %bb.1.left(0x7ffff800), %bb.3.right(0x00000800)
58    liveins: %esi, %rdi
59
60    frame-setup PUSH64r undef %rax, implicit-def %rsp, implicit %rsp
61    CFI_INSTRUCTION def_cfa_offset 16
62    TEST8ri %sil, 1, implicit-def %eflags, implicit killed %esi
63    JE_1 %bb.3.right, implicit killed %eflags
64
65  bb.1.left:
66    successors: %bb.2.null(0x7ffff800), %bb.4.not_null(0x00000800)
67    liveins: %rdi
68
69    %eax = FAULTING_LOAD_OP %bb.2.null, 1684, killed %rdi, 1, _, 0, _ :: (load 4 from %ir.ptr)
70    JMP_1 %bb.4.not_null
71
72  bb.4.not_null:
73    liveins: %rdi, %eax
74
75    %rcx = POP64r implicit-def %rsp, implicit %rsp
76    RETQ %eax
77
78  bb.2.null:
79    liveins: %rdi
80
81    CALL64pcrel32 @stub, csr_64, implicit %rsp, implicit %rdi, implicit-def %rsp
82
83  bb.3.right:
84    dead %edi = XOR32rr undef %edi, undef %edi, implicit-def dead %eflags, implicit-def %rdi
85    CALL64pcrel32 @stub, csr_64, implicit %rsp, implicit %rdi, implicit-def %rsp
86
87...
88