reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
; RUN: opt -S < %s  -partial-inliner -partial-inlining-extra-penalty=10 | FileCheck %s
; RUN: opt -S < %s  -passes=partial-inliner -partial-inlining-extra-penalty=10 | FileCheck %s
define i32 @outline_region_notlikely(i32* %arg) local_unnamed_addr {
bb:
;  ptr != null is predicted to be true 
  %tmp = icmp ne i32* %arg, null
  br i1 %tmp, label %bb8, label %bb1

; bb1 is not likely
bb1:                                              ; preds = %bb
  %tmp2 = tail call i32 @foo(i32* nonnull %arg)
  %tmp3 = tail call i32 @foo(i32* nonnull %arg)
  %tmp4 = tail call i32 @foo(i32* nonnull %arg)
  %tmp5 = tail call i32 @foo(i32* nonnull %arg)
  %tmp6 = tail call i32 @foo(i32* nonnull %arg)
  %tmp7 = tail call i32 @foo(i32* nonnull %arg)
  br label %bb8

bb8:                                              ; preds = %bb1, %bb
  %tmp9 = phi i32 [ 0, %bb1 ], [ 1, %bb ]
  ret i32 %tmp9
}

define i32 @outline_region_likely(i32* %arg) local_unnamed_addr {
bb:
;  ptr == null is predicted to be false
  %tmp = icmp eq i32* %arg, null
  br i1 %tmp, label %bb8, label %bb1

; bb1 is likely
bb1:                                              ; preds = %bb
  %tmp2 = tail call i32 @foo(i32* nonnull %arg)
  %tmp3 = tail call i32 @foo(i32* nonnull %arg)
  %tmp4 = tail call i32 @foo(i32* nonnull %arg)
  %tmp5 = tail call i32 @foo(i32* nonnull %arg)
  %tmp6 = tail call i32 @foo(i32* nonnull %arg)
  %tmp7 = tail call i32 @foo(i32* nonnull %arg)
  br label %bb8

bb8:                                              ; preds = %bb1, %bb
  %tmp9 = phi i32 [ 0, %bb1 ], [ 1, %bb ]
  ret i32 %tmp9
}

declare i32 @foo(i32* %arg)

define i32 @dummy_caller(i32* %arg) local_unnamed_addr {
; CHECK-LABEL: @dummy_caller
  %tmp = call i32 @outline_region_notlikely(i32* %arg)
; CHECK:  call void @outline_region_notlikely.2.bb1
  %tmp2 = tail call i32 @outline_region_likely(i32* %arg)
; CHECK: %tmp2 = tail call i32 @outline_region_likely(i32* %arg)
  ret i32 %tmp

}

; CHECK-LABEL: define internal void @outline_region_notlikely.2.bb1(i32* %arg) {
; CHECK-NEXT: newFuncRoot:

!llvm.module.flags = !{!0}
!llvm.ident = !{!1}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{!"clang version 5.0.0 (trunk 304489)"}