You've already forked linux-packaging-mono
Imported Upstream version 5.18.0.167
Former-commit-id: 289509151e0fee68a1b591a20c9f109c3c789d3a
This commit is contained in:
parent
e19d552987
commit
b084638f15
@ -1,22 +0,0 @@
|
||||
; RUN: opt -lower-expect -S < %s
|
||||
; RUN: opt -passes='function(lower-expect)' -S < %s
|
||||
|
||||
define i64 @foo(i64 %arg) #0 {
|
||||
bb:
|
||||
%tmp = alloca i64, align 8
|
||||
store i64 %arg, i64* %tmp, align 8
|
||||
%tmp1 = load i64, i64* %tmp, align 8
|
||||
%tmp2 = load i64, i64* %tmp, align 8
|
||||
%tmp3 = call i64 @llvm.expect.i64(i64 %tmp1, i64 %tmp2)
|
||||
ret i64 %tmp3
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind readnone
|
||||
declare i64 @llvm.expect.i64(i64, i64)
|
||||
|
||||
|
||||
!llvm.module.flags = !{!0}
|
||||
!llvm.ident = !{!1}
|
||||
|
||||
!0 = !{i32 1, !"wchar_size", i32 4}
|
||||
!1 = !{!"clang version 5.0.0 (trunk 304723)"}
|
@ -1,291 +0,0 @@
|
||||
; RUN: opt -lower-expect -strip-dead-prototypes -S -o - < %s | FileCheck %s
|
||||
; RUN: opt -S -passes='function(lower-expect),strip-dead-prototypes' < %s | FileCheck %s
|
||||
|
||||
; CHECK-LABEL: @test1(
|
||||
define i32 @test1(i32 %x) nounwind uwtable ssp {
|
||||
entry:
|
||||
%retval = alloca i32, align 4
|
||||
%x.addr = alloca i32, align 4
|
||||
store i32 %x, i32* %x.addr, align 4
|
||||
%tmp = load i32, i32* %x.addr, align 4
|
||||
%cmp = icmp sgt i32 %tmp, 1
|
||||
%conv = zext i1 %cmp to i32
|
||||
%conv1 = sext i32 %conv to i64
|
||||
%expval = call i64 @llvm.expect.i64(i64 %conv1, i64 1)
|
||||
%tobool = icmp ne i64 %expval, 0
|
||||
; CHECK: !prof !0
|
||||
; CHECK-NOT: @llvm.expect
|
||||
br i1 %tobool, label %if.then, label %if.end
|
||||
|
||||
if.then: ; preds = %entry
|
||||
%call = call i32 (...) @f()
|
||||
store i32 %call, i32* %retval
|
||||
br label %return
|
||||
|
||||
if.end: ; preds = %entry
|
||||
store i32 1, i32* %retval
|
||||
br label %return
|
||||
|
||||
return: ; preds = %if.end, %if.then
|
||||
%0 = load i32, i32* %retval
|
||||
ret i32 %0
|
||||
}
|
||||
|
||||
declare i64 @llvm.expect.i64(i64, i64) nounwind readnone
|
||||
|
||||
declare i32 @f(...)
|
||||
|
||||
; CHECK-LABEL: @test2(
|
||||
define i32 @test2(i32 %x) nounwind uwtable ssp {
|
||||
entry:
|
||||
%retval = alloca i32, align 4
|
||||
%x.addr = alloca i32, align 4
|
||||
store i32 %x, i32* %x.addr, align 4
|
||||
%tmp = load i32, i32* %x.addr, align 4
|
||||
%conv = sext i32 %tmp to i64
|
||||
%expval = call i64 @llvm.expect.i64(i64 %conv, i64 1)
|
||||
%tobool = icmp ne i64 %expval, 0
|
||||
; CHECK: !prof !0
|
||||
; CHECK-NOT: @llvm.expect
|
||||
br i1 %tobool, label %if.then, label %if.end
|
||||
|
||||
if.then: ; preds = %entry
|
||||
%call = call i32 (...) @f()
|
||||
store i32 %call, i32* %retval
|
||||
br label %return
|
||||
|
||||
if.end: ; preds = %entry
|
||||
store i32 1, i32* %retval
|
||||
br label %return
|
||||
|
||||
return: ; preds = %if.end, %if.then
|
||||
%0 = load i32, i32* %retval
|
||||
ret i32 %0
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @test3(
|
||||
define i32 @test3(i32 %x) nounwind uwtable ssp {
|
||||
entry:
|
||||
%retval = alloca i32, align 4
|
||||
%x.addr = alloca i32, align 4
|
||||
store i32 %x, i32* %x.addr, align 4
|
||||
%tmp = load i32, i32* %x.addr, align 4
|
||||
%tobool = icmp ne i32 %tmp, 0
|
||||
%lnot = xor i1 %tobool, true
|
||||
%lnot.ext = zext i1 %lnot to i32
|
||||
%conv = sext i32 %lnot.ext to i64
|
||||
%expval = call i64 @llvm.expect.i64(i64 %conv, i64 1)
|
||||
%tobool1 = icmp ne i64 %expval, 0
|
||||
; CHECK: !prof !0
|
||||
; CHECK-NOT: @llvm.expect
|
||||
br i1 %tobool1, label %if.then, label %if.end
|
||||
|
||||
if.then: ; preds = %entry
|
||||
%call = call i32 (...) @f()
|
||||
store i32 %call, i32* %retval
|
||||
br label %return
|
||||
|
||||
if.end: ; preds = %entry
|
||||
store i32 1, i32* %retval
|
||||
br label %return
|
||||
|
||||
return: ; preds = %if.end, %if.then
|
||||
%0 = load i32, i32* %retval
|
||||
ret i32 %0
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @test4(
|
||||
define i32 @test4(i32 %x) nounwind uwtable ssp {
|
||||
entry:
|
||||
%retval = alloca i32, align 4
|
||||
%x.addr = alloca i32, align 4
|
||||
store i32 %x, i32* %x.addr, align 4
|
||||
%tmp = load i32, i32* %x.addr, align 4
|
||||
%tobool = icmp ne i32 %tmp, 0
|
||||
%lnot = xor i1 %tobool, true
|
||||
%lnot1 = xor i1 %lnot, true
|
||||
%lnot.ext = zext i1 %lnot1 to i32
|
||||
%conv = sext i32 %lnot.ext to i64
|
||||
%expval = call i64 @llvm.expect.i64(i64 %conv, i64 1)
|
||||
%tobool2 = icmp ne i64 %expval, 0
|
||||
; CHECK: !prof !0
|
||||
; CHECK-NOT: @llvm.expect
|
||||
br i1 %tobool2, label %if.then, label %if.end
|
||||
|
||||
if.then: ; preds = %entry
|
||||
%call = call i32 (...) @f()
|
||||
store i32 %call, i32* %retval
|
||||
br label %return
|
||||
|
||||
if.end: ; preds = %entry
|
||||
store i32 1, i32* %retval
|
||||
br label %return
|
||||
|
||||
return: ; preds = %if.end, %if.then
|
||||
%0 = load i32, i32* %retval
|
||||
ret i32 %0
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @test5(
|
||||
define i32 @test5(i32 %x) nounwind uwtable ssp {
|
||||
entry:
|
||||
%retval = alloca i32, align 4
|
||||
%x.addr = alloca i32, align 4
|
||||
store i32 %x, i32* %x.addr, align 4
|
||||
%tmp = load i32, i32* %x.addr, align 4
|
||||
%cmp = icmp slt i32 %tmp, 0
|
||||
%conv = zext i1 %cmp to i32
|
||||
%conv1 = sext i32 %conv to i64
|
||||
%expval = call i64 @llvm.expect.i64(i64 %conv1, i64 0)
|
||||
%tobool = icmp ne i64 %expval, 0
|
||||
; CHECK: !prof !1
|
||||
; CHECK-NOT: @llvm.expect
|
||||
br i1 %tobool, label %if.then, label %if.end
|
||||
|
||||
if.then: ; preds = %entry
|
||||
%call = call i32 (...) @f()
|
||||
store i32 %call, i32* %retval
|
||||
br label %return
|
||||
|
||||
if.end: ; preds = %entry
|
||||
store i32 1, i32* %retval
|
||||
br label %return
|
||||
|
||||
return: ; preds = %if.end, %if.then
|
||||
%0 = load i32, i32* %retval
|
||||
ret i32 %0
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @test6(
|
||||
define i32 @test6(i32 %x) nounwind uwtable ssp {
|
||||
entry:
|
||||
%retval = alloca i32, align 4
|
||||
%x.addr = alloca i32, align 4
|
||||
store i32 %x, i32* %x.addr, align 4
|
||||
%tmp = load i32, i32* %x.addr, align 4
|
||||
%conv = sext i32 %tmp to i64
|
||||
%expval = call i64 @llvm.expect.i64(i64 %conv, i64 1)
|
||||
; CHECK: !prof !2
|
||||
; CHECK-NOT: @llvm.expect
|
||||
switch i64 %expval, label %sw.epilog [
|
||||
i64 1, label %sw.bb
|
||||
i64 2, label %sw.bb
|
||||
]
|
||||
|
||||
sw.bb: ; preds = %entry, %entry
|
||||
store i32 0, i32* %retval
|
||||
br label %return
|
||||
|
||||
sw.epilog: ; preds = %entry
|
||||
store i32 1, i32* %retval
|
||||
br label %return
|
||||
|
||||
return: ; preds = %sw.epilog, %sw.bb
|
||||
%0 = load i32, i32* %retval
|
||||
ret i32 %0
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @test7(
|
||||
define i32 @test7(i32 %x) nounwind uwtable ssp {
|
||||
entry:
|
||||
%retval = alloca i32, align 4
|
||||
%x.addr = alloca i32, align 4
|
||||
store i32 %x, i32* %x.addr, align 4
|
||||
%tmp = load i32, i32* %x.addr, align 4
|
||||
%conv = sext i32 %tmp to i64
|
||||
%expval = call i64 @llvm.expect.i64(i64 %conv, i64 1)
|
||||
; CHECK: !prof !3
|
||||
; CHECK-NOT: @llvm.expect
|
||||
switch i64 %expval, label %sw.epilog [
|
||||
i64 2, label %sw.bb
|
||||
i64 3, label %sw.bb
|
||||
]
|
||||
|
||||
sw.bb: ; preds = %entry, %entry
|
||||
%tmp1 = load i32, i32* %x.addr, align 4
|
||||
store i32 %tmp1, i32* %retval
|
||||
br label %return
|
||||
|
||||
sw.epilog: ; preds = %entry
|
||||
store i32 0, i32* %retval
|
||||
br label %return
|
||||
|
||||
return: ; preds = %sw.epilog, %sw.bb
|
||||
%0 = load i32, i32* %retval
|
||||
ret i32 %0
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @test8(
|
||||
define i32 @test8(i32 %x) nounwind uwtable ssp {
|
||||
entry:
|
||||
%retval = alloca i32, align 4
|
||||
%x.addr = alloca i32, align 4
|
||||
store i32 %x, i32* %x.addr, align 4
|
||||
%tmp = load i32, i32* %x.addr, align 4
|
||||
%cmp = icmp sgt i32 %tmp, 1
|
||||
%conv = zext i1 %cmp to i32
|
||||
%expval = call i32 @llvm.expect.i32(i32 %conv, i32 1)
|
||||
%tobool = icmp ne i32 %expval, 0
|
||||
; CHECK: !prof !0
|
||||
; CHECK-NOT: @llvm.expect
|
||||
br i1 %tobool, label %if.then, label %if.end
|
||||
|
||||
if.then: ; preds = %entry
|
||||
%call = call i32 (...) @f()
|
||||
store i32 %call, i32* %retval
|
||||
br label %return
|
||||
|
||||
if.end: ; preds = %entry
|
||||
store i32 1, i32* %retval
|
||||
br label %return
|
||||
|
||||
return: ; preds = %if.end, %if.then
|
||||
%0 = load i32, i32* %retval
|
||||
ret i32 %0
|
||||
}
|
||||
|
||||
declare i32 @llvm.expect.i32(i32, i32) nounwind readnone
|
||||
|
||||
; CHECK-LABEL: @test9(
|
||||
define i32 @test9(i32 %x) nounwind uwtable ssp {
|
||||
entry:
|
||||
%retval = alloca i32, align 4
|
||||
%x.addr = alloca i32, align 4
|
||||
store i32 %x, i32* %x.addr, align 4
|
||||
%tmp = load i32, i32* %x.addr, align 4
|
||||
%cmp = icmp sgt i32 %tmp, 1
|
||||
%expval = call i1 @llvm.expect.i1(i1 %cmp, i1 1)
|
||||
; CHECK: !prof !0
|
||||
; CHECK-NOT: @llvm.expect
|
||||
br i1 %expval, label %if.then, label %if.end
|
||||
|
||||
if.then: ; preds = %entry
|
||||
%call = call i32 (...) @f()
|
||||
store i32 %call, i32* %retval
|
||||
br label %return
|
||||
|
||||
if.end: ; preds = %entry
|
||||
store i32 1, i32* %retval
|
||||
br label %return
|
||||
|
||||
return: ; preds = %if.end, %if.then
|
||||
%0 = load i32, i32* %retval
|
||||
ret i32 %0
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @test10(
|
||||
define i32 @test10(i64 %t6) {
|
||||
%t7 = call i64 @llvm.expect.i64(i64 %t6, i64 0)
|
||||
%t8 = icmp ne i64 %t7, 0
|
||||
%t9 = select i1 %t8, i32 1, i32 2
|
||||
; CHECK: select{{.*}}, !prof !1
|
||||
ret i32 %t9
|
||||
}
|
||||
|
||||
|
||||
declare i1 @llvm.expect.i1(i1, i1) nounwind readnone
|
||||
|
||||
; CHECK: !0 = !{!"branch_weights", i32 2000, i32 1}
|
||||
; CHECK: !1 = !{!"branch_weights", i32 1, i32 2000}
|
||||
; CHECK: !2 = !{!"branch_weights", i32 1, i32 2000, i32 1}
|
||||
; CHECK: !3 = !{!"branch_weights", i32 2000, i32 1, i32 1}
|
@ -1,104 +0,0 @@
|
||||
; RUN: opt -lower-expect -S -o - < %s | FileCheck %s
|
||||
; RUN: opt -S -passes='function(lower-expect)' < %s | FileCheck %s
|
||||
|
||||
define i32 @foo(i32 %arg) #0 {
|
||||
; CHECK-LABEL: @foo(i32{{.*}})
|
||||
bb:
|
||||
%tmp = sext i32 %arg to i64
|
||||
%tmp1 = call i64 @llvm.expect.i64(i64 %tmp, i64 4)
|
||||
%tmp2 = icmp ne i64 %tmp1, 0
|
||||
br i1 %tmp2, label %bb3, label %bb5
|
||||
; CHECK: br i1 %tmp2{{.*}}!prof [[LIKELY:![0-9]+]]
|
||||
|
||||
bb3: ; preds = %bb
|
||||
%tmp4 = call i32 (...) @bar()
|
||||
br label %bb5
|
||||
|
||||
bb5: ; preds = %bb3, %bb
|
||||
ret i32 1
|
||||
}
|
||||
|
||||
define i32 @foo2(i32 %arg) #0 {
|
||||
; CHECK-LABEL: @foo2
|
||||
bb:
|
||||
%tmp = sext i32 %arg to i64
|
||||
%tmp1 = call i64 @llvm.expect.i64(i64 %tmp, i64 4)
|
||||
%tmp2 = icmp eq i64 %tmp1, 2
|
||||
br i1 %tmp2, label %bb3, label %bb5
|
||||
; CHECK: br i1 %tmp2{{.*}}!prof [[UNLIKELY:![0-9]+]]
|
||||
|
||||
bb3: ; preds = %bb
|
||||
%tmp4 = call i32 (...) @bar()
|
||||
br label %bb5
|
||||
|
||||
bb5: ; preds = %bb3, %bb
|
||||
ret i32 1
|
||||
}
|
||||
|
||||
define i32 @foo3(i32 %arg) #0 {
|
||||
; CHECK-LABEL: @foo3
|
||||
bb:
|
||||
%tmp = sext i32 %arg to i64
|
||||
%tmp1 = call i64 @llvm.expect.i64(i64 %tmp, i64 4)
|
||||
%tmp2 = icmp eq i64 %tmp1, 4
|
||||
br i1 %tmp2, label %bb3, label %bb5
|
||||
; CHECK: br i1 %tmp2{{.*}}!prof [[LIKELY]]
|
||||
|
||||
bb3: ; preds = %bb
|
||||
%tmp4 = call i32 (...) @bar()
|
||||
br label %bb5
|
||||
|
||||
bb5: ; preds = %bb3, %bb
|
||||
ret i32 1
|
||||
}
|
||||
|
||||
define i32 @foo4(i32 %arg) #0 {
|
||||
; CHECK-LABEL: @foo4
|
||||
bb:
|
||||
%tmp = sext i32 %arg to i64
|
||||
%tmp1 = call i64 @llvm.expect.i64(i64 %tmp, i64 4)
|
||||
%tmp2 = icmp ne i64 %tmp1, 2
|
||||
br i1 %tmp2, label %bb3, label %bb5
|
||||
; CHECK: br i1 %tmp2{{.*}}!prof [[LIKELY]]
|
||||
|
||||
bb3: ; preds = %bb
|
||||
%tmp4 = call i32 (...) @bar()
|
||||
br label %bb5
|
||||
|
||||
bb5: ; preds = %bb3, %bb
|
||||
ret i32 1
|
||||
}
|
||||
|
||||
define i32 @foo5(i32 %arg, i32 %arg1) #0 {
|
||||
; CHECK-LABEL: @foo5
|
||||
bb:
|
||||
%tmp = sext i32 %arg1 to i64
|
||||
%tmp2 = call i64 @llvm.expect.i64(i64 %tmp, i64 4)
|
||||
%tmp3 = sext i32 %arg to i64
|
||||
%tmp4 = icmp ne i64 %tmp2, %tmp3
|
||||
br i1 %tmp4, label %bb5, label %bb7
|
||||
; CHECK-NOT: !prof
|
||||
|
||||
bb5: ; preds = %bb
|
||||
%tmp6 = call i32 (...) @bar()
|
||||
br label %bb7
|
||||
|
||||
bb7: ; preds = %bb5, %bb
|
||||
ret i32 1
|
||||
}
|
||||
|
||||
declare i64 @llvm.expect.i64(i64, i64) #1
|
||||
|
||||
declare i32 @bar(...) local_unnamed_addr #0
|
||||
|
||||
attributes #0 = { nounwind uwtable }
|
||||
attributes #1 = { nounwind readnone }
|
||||
|
||||
!llvm.module.flags = !{!0}
|
||||
!llvm.ident = !{!1}
|
||||
|
||||
!0 = !{i32 1, !"wchar_size", i32 4}
|
||||
!1 = !{!"clang version 5.0.0 (trunk 304373)"}
|
||||
; CHECK: [[LIKELY]] = !{!"branch_weights", i32 2000, i32 1}
|
||||
; CHECK: [[UNLIKELY]] = !{!"branch_weights", i32 1, i32 2000}
|
||||
|
@ -1,356 +0,0 @@
|
||||
; RUN: opt -lower-expect -S -o - < %s | FileCheck %s
|
||||
; RUN: opt -S -passes='function(lower-expect)' < %s | FileCheck %s
|
||||
|
||||
; The C case
|
||||
; if (__builtin_expect((x > goo() && y > hoo() && z > too()), 1))
|
||||
; For the above case, all 3 branches should be annotated.
|
||||
;
|
||||
; if (__builtin_expect((x > goo() && y > hoo() && z > too()), 0))
|
||||
; For the above case, we don't have enough information, so
|
||||
; only the last branch is annotated.
|
||||
|
||||
define void @foo(i32 %arg, i32 %arg1, i32 %arg2, i32 %arg3) {
|
||||
; CHECK-LABEL: void @foo
|
||||
bb:
|
||||
%tmp8 = call i32 @goo()
|
||||
%tmp9 = icmp sgt i32 %tmp8, %arg
|
||||
br i1 %tmp9, label %bb10, label %bb18
|
||||
; CHECK: !prof [[WEIGHT:![0-9]+]]
|
||||
|
||||
bb10: ; preds = %bb
|
||||
%tmp12 = call i32 @hoo()
|
||||
%tmp13 = icmp sgt i32 %arg1, %tmp12
|
||||
br i1 %tmp13, label %bb14, label %bb18
|
||||
; CHECK: br i1 %tmp13, {{.*}}!prof [[WEIGHT]]
|
||||
|
||||
bb14: ; preds = %bb10
|
||||
%tmp16 = call i32 @too()
|
||||
%tmp17 = icmp sgt i32 %arg2, %tmp16
|
||||
br label %bb18
|
||||
|
||||
bb18: ; preds = %bb14, %bb10, %bb
|
||||
%tmp19 = phi i1 [ false, %bb10 ], [ false, %bb ], [ %tmp17, %bb14 ]
|
||||
%tmp20 = xor i1 %tmp19, true
|
||||
%tmp21 = xor i1 %tmp20, true
|
||||
%tmp22 = zext i1 %tmp21 to i32
|
||||
%tmp23 = sext i32 %tmp22 to i64
|
||||
%tmp24 = call i64 @llvm.expect.i64(i64 %tmp23, i64 1)
|
||||
%tmp25 = icmp ne i64 %tmp24, 0
|
||||
br i1 %tmp25, label %bb26, label %bb28
|
||||
; CHECK: br i1 %tmp25,{{.*}}!prof [[WEIGHT]]
|
||||
|
||||
bb26: ; preds = %bb18
|
||||
%tmp27 = call i32 @goo()
|
||||
br label %bb30
|
||||
|
||||
bb28: ; preds = %bb18
|
||||
%tmp29 = call i32 @hoo()
|
||||
br label %bb30
|
||||
|
||||
bb30: ; preds = %bb28, %bb26
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @foo2(i32 %arg, i32 %arg1, i32 %arg2, i32 %arg3) {
|
||||
; CHECK-LABEL: void @foo2
|
||||
bb:
|
||||
%tmp8 = call i32 @goo()
|
||||
%tmp9 = icmp sgt i32 %tmp8, %arg
|
||||
br i1 %tmp9, label %bb10, label %bb18
|
||||
; CHECK: br i1 %tmp9
|
||||
; CHECK-NOT: !prof
|
||||
|
||||
bb10: ; preds = %bb
|
||||
%tmp12 = call i32 @hoo()
|
||||
%tmp13 = icmp sgt i32 %arg1, %tmp12
|
||||
br i1 %tmp13, label %bb14, label %bb18
|
||||
; CHECK: br i1 %tmp13
|
||||
; CHECK-NOT: !prof
|
||||
|
||||
bb14: ; preds = %bb10
|
||||
%tmp16 = call i32 @too()
|
||||
%tmp17 = icmp sgt i32 %arg2, %tmp16
|
||||
br label %bb18
|
||||
|
||||
bb18: ; preds = %bb14, %bb10, %bb
|
||||
%tmp19 = phi i1 [ false, %bb10 ], [ false, %bb ], [ %tmp17, %bb14 ]
|
||||
%tmp20 = xor i1 %tmp19, true
|
||||
%tmp21 = xor i1 %tmp20, true
|
||||
%tmp22 = zext i1 %tmp21 to i32
|
||||
%tmp23 = sext i32 %tmp22 to i64
|
||||
%tmp24 = call i64 @llvm.expect.i64(i64 %tmp23, i64 0)
|
||||
%tmp25 = icmp ne i64 %tmp24, 0
|
||||
br i1 %tmp25, label %bb26, label %bb28
|
||||
; CHECK: br i1 %tmp25,{{.*}}!prof [[WEIGHT2:![0-9]+]]
|
||||
|
||||
bb26: ; preds = %bb18
|
||||
%tmp27 = call i32 @goo()
|
||||
br label %bb30
|
||||
|
||||
bb28: ; preds = %bb18
|
||||
%tmp29 = call i32 @hoo()
|
||||
br label %bb30
|
||||
|
||||
bb30: ; preds = %bb28, %bb26
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @foo_i32(i32 %arg, i32 %arg1, i32 %arg2, i32 %arg3) {
|
||||
; CHECK-LABEL: void @foo_i32
|
||||
bb:
|
||||
%tmp8 = call i32 @goo()
|
||||
%tmp9 = icmp sgt i32 %tmp8, %arg
|
||||
br i1 %tmp9, label %bb10, label %bb18
|
||||
; CHECK: !prof [[WEIGHT]]
|
||||
|
||||
bb10: ; preds = %bb
|
||||
%tmp12 = call i32 @hoo()
|
||||
%tmp13 = icmp sgt i32 %arg1, %tmp12
|
||||
br i1 %tmp13, label %bb14, label %bb18
|
||||
; CHECK: br i1 %tmp13, {{.*}}!prof [[WEIGHT]]
|
||||
|
||||
bb14: ; preds = %bb10
|
||||
%tmp16 = call i32 @too()
|
||||
%tmp17 = icmp sgt i32 %arg2, %tmp16
|
||||
br label %bb18
|
||||
|
||||
bb18: ; preds = %bb14, %bb10, %bb
|
||||
%tmp19 = phi i32 [ 5, %bb10 ], [ 5, %bb ], [ %tmp16, %bb14 ]
|
||||
%tmp23 = sext i32 %tmp19 to i64
|
||||
%tmp24 = call i64 @llvm.expect.i64(i64 %tmp23, i64 4)
|
||||
%tmp25 = icmp ne i64 %tmp24, 0
|
||||
br i1 %tmp25, label %bb26, label %bb28
|
||||
; CHECK: br i1 %tmp25,{{.*}}!prof [[WEIGHT]]
|
||||
|
||||
bb26: ; preds = %bb18
|
||||
%tmp27 = call i32 @goo()
|
||||
br label %bb30
|
||||
|
||||
bb28: ; preds = %bb18
|
||||
%tmp29 = call i32 @hoo()
|
||||
br label %bb30
|
||||
|
||||
bb30: ; preds = %bb28, %bb26
|
||||
ret void
|
||||
}
|
||||
|
||||
|
||||
define void @foo_i32_not_unlikely(i32 %arg, i32 %arg1, i32 %arg2, i32 %arg3) {
|
||||
; CHECK-LABEL: void @foo_i32_not_unlikely
|
||||
bb:
|
||||
%tmp8 = call i32 @goo()
|
||||
%tmp9 = icmp sgt i32 %tmp8, %arg
|
||||
br i1 %tmp9, label %bb10, label %bb18
|
||||
; CHECK: br i1 %tmp9
|
||||
; CHECK-NOT: !prof
|
||||
|
||||
bb10: ; preds = %bb
|
||||
%tmp12 = call i32 @hoo()
|
||||
%tmp13 = icmp sgt i32 %arg1, %tmp12
|
||||
br i1 %tmp13, label %bb14, label %bb18
|
||||
; CHECK: br i1 %tmp13
|
||||
; CHECK-NOT: !prof
|
||||
|
||||
bb14: ; preds = %bb10
|
||||
%tmp16 = call i32 @too()
|
||||
%tmp17 = icmp sgt i32 %arg2, %tmp16
|
||||
br label %bb18
|
||||
|
||||
bb18: ; preds = %bb14, %bb10, %bb
|
||||
%tmp19 = phi i32 [ 4, %bb10 ], [ 4, %bb ], [ %tmp16, %bb14 ]
|
||||
%tmp23 = sext i32 %tmp19 to i64
|
||||
%tmp24 = call i64 @llvm.expect.i64(i64 %tmp23, i64 4)
|
||||
%tmp25 = icmp ne i64 %tmp24, 0
|
||||
br i1 %tmp25, label %bb26, label %bb28
|
||||
; CHECK: br i1 %tmp25,{{.*}}!prof [[WEIGHT]]
|
||||
|
||||
bb26: ; preds = %bb18
|
||||
%tmp27 = call i32 @goo()
|
||||
br label %bb30
|
||||
|
||||
bb28: ; preds = %bb18
|
||||
%tmp29 = call i32 @hoo()
|
||||
br label %bb30
|
||||
|
||||
bb30: ; preds = %bb28, %bb26
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @foo_i32_xor(i32 %arg, i32 %arg1, i32 %arg2, i32 %arg3) {
|
||||
; CHECK-LABEL: void @foo_i32_xor
|
||||
bb:
|
||||
%tmp8 = call i32 @goo()
|
||||
%tmp9 = icmp sgt i32 %tmp8, %arg
|
||||
br i1 %tmp9, label %bb10, label %bb18
|
||||
; CHECK: br i1 %tmp9,{{.*}}!prof [[WEIGHT]]
|
||||
|
||||
bb10: ; preds = %bb
|
||||
%tmp12 = call i32 @hoo()
|
||||
%tmp13 = icmp sgt i32 %arg1, %tmp12
|
||||
br i1 %tmp13, label %bb14, label %bb18
|
||||
; CHECK: br i1 %tmp13,{{.*}}!prof [[WEIGHT]]
|
||||
|
||||
bb14: ; preds = %bb10
|
||||
%tmp16 = call i32 @too()
|
||||
%tmp17 = icmp sgt i32 %arg2, %tmp16
|
||||
br label %bb18
|
||||
|
||||
bb18: ; preds = %bb14, %bb10, %bb
|
||||
%tmp19 = phi i32 [ 6, %bb10 ], [ 6, %bb ], [ %tmp16, %bb14 ]
|
||||
%tmp20 = xor i32 %tmp19, 3
|
||||
%tmp23 = sext i32 %tmp20 to i64
|
||||
%tmp24 = call i64 @llvm.expect.i64(i64 %tmp23, i64 4)
|
||||
%tmp25 = icmp ne i64 %tmp24, 0
|
||||
br i1 %tmp25, label %bb26, label %bb28
|
||||
; CHECK: br i1 %tmp25,{{.*}}!prof [[WEIGHT]]
|
||||
|
||||
bb26: ; preds = %bb18
|
||||
%tmp27 = call i32 @goo()
|
||||
br label %bb30
|
||||
|
||||
bb28: ; preds = %bb18
|
||||
%tmp29 = call i32 @hoo()
|
||||
br label %bb30
|
||||
bb30: ; preds = %bb28, %bb26
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @foo_i8_sext(i32 %arg, i32 %arg1, i8 %arg2, i32 %arg3) {
|
||||
; CHECK-LABEL: void @foo_i8_sext
|
||||
bb:
|
||||
%tmp8 = call i32 @goo()
|
||||
%tmp9 = icmp sgt i32 %tmp8, %arg
|
||||
br i1 %tmp9, label %bb10, label %bb18
|
||||
; CHECK: br i1 %tmp9,{{.*}}!prof [[WEIGHT]]
|
||||
|
||||
bb10: ; preds = %bb
|
||||
%tmp12 = call i32 @hoo()
|
||||
%tmp13 = icmp sgt i32 %arg1, %tmp12
|
||||
br i1 %tmp13, label %bb14, label %bb18
|
||||
; CHECK: br i1 %tmp13,{{.*}}!prof [[WEIGHT]]
|
||||
|
||||
bb14: ; preds = %bb10
|
||||
%tmp16 = call i8 @too8()
|
||||
%tmp17 = icmp sgt i8 %arg2, %tmp16
|
||||
br label %bb18
|
||||
|
||||
bb18: ; preds = %bb14, %bb10, %bb
|
||||
%tmp19 = phi i8 [ 255, %bb10 ], [ 255, %bb ], [ %tmp16, %bb14 ]
|
||||
%tmp23 = sext i8 %tmp19 to i64
|
||||
; after sign extension, the operand value becomes -1 which does not match 255
|
||||
%tmp24 = call i64 @llvm.expect.i64(i64 %tmp23, i64 255)
|
||||
%tmp25 = icmp ne i64 %tmp24, 0
|
||||
br i1 %tmp25, label %bb26, label %bb28
|
||||
; CHECK: br i1 %tmp25,{{.*}}!prof [[WEIGHT]]
|
||||
|
||||
bb26: ; preds = %bb18
|
||||
%tmp27 = call i32 @goo()
|
||||
br label %bb30
|
||||
|
||||
bb28: ; preds = %bb18
|
||||
%tmp29 = call i32 @hoo()
|
||||
br label %bb30
|
||||
bb30: ; preds = %bb28, %bb26
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @foo_i8_sext_not_unlikely(i32 %arg, i32 %arg1, i8 %arg2, i32 %arg3) {
|
||||
; CHECK-LABEL: void @foo_i8_sext_not_unlikely
|
||||
bb:
|
||||
%tmp8 = call i32 @goo()
|
||||
%tmp9 = icmp sgt i32 %tmp8, %arg
|
||||
br i1 %tmp9, label %bb10, label %bb18
|
||||
; CHECK: br i1 %tmp9
|
||||
; CHECK-NOT: !prof
|
||||
|
||||
bb10: ; preds = %bb
|
||||
%tmp12 = call i32 @hoo()
|
||||
%tmp13 = icmp sgt i32 %arg1, %tmp12
|
||||
br i1 %tmp13, label %bb14, label %bb18
|
||||
; CHECK: br i1 %tmp13
|
||||
; CHECK-NOT: !prof
|
||||
|
||||
bb14: ; preds = %bb10
|
||||
%tmp16 = call i8 @too8()
|
||||
%tmp17 = icmp sgt i8 %arg2, %tmp16
|
||||
br label %bb18
|
||||
|
||||
bb18: ; preds = %bb14, %bb10, %bb
|
||||
%tmp19 = phi i8 [ 255, %bb10 ], [ 255, %bb ], [ %tmp16, %bb14 ]
|
||||
%tmp23 = sext i8 %tmp19 to i64
|
||||
; after sign extension, the operand value becomes -1 which matches -1
|
||||
%tmp24 = call i64 @llvm.expect.i64(i64 %tmp23, i64 -1)
|
||||
%tmp25 = icmp ne i64 %tmp24, 0
|
||||
br i1 %tmp25, label %bb26, label %bb28
|
||||
; CHECK: br i1 %tmp25,{{.*}}!prof [[WEIGHT]]
|
||||
|
||||
bb26: ; preds = %bb18
|
||||
%tmp27 = call i32 @goo()
|
||||
br label %bb30
|
||||
|
||||
bb28: ; preds = %bb18
|
||||
%tmp29 = call i32 @hoo()
|
||||
br label %bb30
|
||||
bb30: ; preds = %bb28, %bb26
|
||||
ret void
|
||||
}
|
||||
|
||||
|
||||
define void @foo_i32_xor_not_unlikely(i32 %arg, i32 %arg1, i32 %arg2, i32 %arg3) {
|
||||
; CHECK-LABEL: void @foo_i32_xor_not_unlikely
|
||||
bb:
|
||||
%tmp8 = call i32 @goo()
|
||||
%tmp9 = icmp sgt i32 %tmp8, %arg
|
||||
br i1 %tmp9, label %bb10, label %bb18
|
||||
; CHECK: br i1 %tmp9
|
||||
; CHECK-NOT: !prof
|
||||
|
||||
bb10: ; preds = %bb
|
||||
%tmp12 = call i32 @hoo()
|
||||
%tmp13 = icmp sgt i32 %arg1, %tmp12
|
||||
br i1 %tmp13, label %bb14, label %bb18
|
||||
; CHECK: br i1 %tmp13
|
||||
; CHECK-NOT: !prof
|
||||
|
||||
bb14: ; preds = %bb10
|
||||
%tmp16 = call i32 @too()
|
||||
%tmp17 = icmp sgt i32 %arg2, %tmp16
|
||||
br label %bb18
|
||||
|
||||
bb18: ; preds = %bb14, %bb10, %bb
|
||||
%tmp19 = phi i32 [ 6, %bb10 ], [ 6, %bb ], [ %tmp16, %bb14 ]
|
||||
%tmp20 = xor i32 %tmp19, 2
|
||||
%tmp23 = sext i32 %tmp20 to i64
|
||||
%tmp24 = call i64 @llvm.expect.i64(i64 %tmp23, i64 4)
|
||||
%tmp25 = icmp ne i64 %tmp24, 0
|
||||
br i1 %tmp25, label %bb26, label %bb28
|
||||
; CHECK: br i1 %tmp25,{{.*}}!prof [[WEIGHT]]
|
||||
|
||||
bb26: ; preds = %bb18
|
||||
%tmp27 = call i32 @goo()
|
||||
br label %bb30
|
||||
|
||||
bb28: ; preds = %bb18
|
||||
%tmp29 = call i32 @hoo()
|
||||
br label %bb30
|
||||
|
||||
bb30: ; preds = %bb28, %bb26
|
||||
ret void
|
||||
}
|
||||
|
||||
declare i32 @goo()
|
||||
|
||||
declare i32 @hoo()
|
||||
|
||||
declare i32 @too()
|
||||
|
||||
declare i8 @too8()
|
||||
|
||||
; Function Attrs: nounwind readnone
|
||||
declare i64 @llvm.expect.i64(i64, i64)
|
||||
|
||||
!llvm.ident = !{!0}
|
||||
|
||||
!0 = !{!"clang version 5.0.0 (trunk 302965)"}
|
||||
; CHECK: [[WEIGHT]] = !{!"branch_weights", i32 2000, i32 1}
|
||||
; CHECK: [[WEIGHT2]] = !{!"branch_weights", i32 1, i32 2000}
|
@ -1,103 +0,0 @@
|
||||
; RUN: opt -lower-expect -S -o - < %s | FileCheck %s
|
||||
; RUN: opt -S -passes='function(lower-expect)' < %s | FileCheck %s
|
||||
;
|
||||
; if (__builtin_expect((x > goo() || y > hoo()), 1)) {
|
||||
; ..
|
||||
; }
|
||||
; For the above case, only the second branch should be
|
||||
; annotated.
|
||||
; if (__builtin_expect((x > goo() || y > hoo()), 0)) {
|
||||
; ..
|
||||
; }
|
||||
; For the above case, two branches should be annotated.
|
||||
; Function Attrs: noinline nounwind uwtable
|
||||
define void @foo(i32 %arg, i32 %arg1, i32 %arg2, i32 %arg3) {
|
||||
; CHECK-LABEL: void @foo
|
||||
bb:
|
||||
%tmp8 = call i32 @goo()
|
||||
%tmp9 = icmp slt i32 %arg, %tmp8
|
||||
br i1 %tmp9, label %bb14, label %bb10
|
||||
; CHECK: br i1 %tmp9
|
||||
; CHECK-NOT: br i1 %tmp9{{.*}}!prof
|
||||
|
||||
bb10: ; preds = %bb
|
||||
%tmp12 = call i32 @hoo()
|
||||
%tmp13 = icmp sgt i32 %arg1, %tmp12
|
||||
br label %bb14
|
||||
|
||||
bb14: ; preds = %bb10, %bb
|
||||
%tmp15 = phi i1 [ true, %bb ], [ %tmp13, %bb10 ]
|
||||
%tmp16 = zext i1 %tmp15 to i32
|
||||
%tmp17 = sext i32 %tmp16 to i64
|
||||
%expect = call i64 @llvm.expect.i64(i64 %tmp17, i64 1)
|
||||
%tmp18 = icmp ne i64 %expect, 0
|
||||
br i1 %tmp18, label %bb19, label %bb21
|
||||
; CHECK: br i1 %tmp18{{.*}}!prof [[WEIGHT:![0-9]+]]
|
||||
|
||||
bb19: ; preds = %bb14
|
||||
%tmp20 = call i32 @goo()
|
||||
br label %bb23
|
||||
|
||||
bb21: ; preds = %bb14
|
||||
%tmp22 = call i32 @hoo()
|
||||
br label %bb23
|
||||
|
||||
bb23: ; preds = %bb21, %bb19
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @foo2(i32 %arg, i32 %arg1, i32 %arg2, i32 %arg3) {
|
||||
; CHECK-LABEL: void @foo2
|
||||
bb:
|
||||
%tmp = alloca i32, align 4
|
||||
%tmp4 = alloca i32, align 4
|
||||
%tmp5 = alloca i32, align 4
|
||||
%tmp6 = alloca i32, align 4
|
||||
store i32 %arg, i32* %tmp, align 4
|
||||
store i32 %arg1, i32* %tmp4, align 4
|
||||
store i32 %arg2, i32* %tmp5, align 4
|
||||
store i32 %arg3, i32* %tmp6, align 4
|
||||
%tmp7 = load i32, i32* %tmp, align 4
|
||||
%tmp8 = call i32 @goo()
|
||||
%tmp9 = icmp slt i32 %tmp7, %tmp8
|
||||
br i1 %tmp9, label %bb14, label %bb10
|
||||
; CHECK: br i1 %tmp9{{.*}}!prof [[WEIGHT2:![0-9]+]]
|
||||
|
||||
bb10: ; preds = %bb
|
||||
%tmp11 = load i32, i32* %tmp5, align 4
|
||||
%tmp12 = call i32 @hoo()
|
||||
%tmp13 = icmp sgt i32 %tmp11, %tmp12
|
||||
br label %bb14
|
||||
|
||||
bb14: ; preds = %bb10, %bb
|
||||
%tmp15 = phi i1 [ true, %bb ], [ %tmp13, %bb10 ]
|
||||
%tmp16 = zext i1 %tmp15 to i32
|
||||
%tmp17 = sext i32 %tmp16 to i64
|
||||
%expect = call i64 @llvm.expect.i64(i64 %tmp17, i64 0)
|
||||
%tmp18 = icmp ne i64 %expect, 0
|
||||
br i1 %tmp18, label %bb19, label %bb21
|
||||
; CHECK: br i1 %tmp18{{.*}}!prof [[WEIGHT2]]
|
||||
|
||||
bb19: ; preds = %bb14
|
||||
%tmp20 = call i32 @goo()
|
||||
br label %bb23
|
||||
|
||||
bb21: ; preds = %bb14
|
||||
%tmp22 = call i32 @hoo()
|
||||
br label %bb23
|
||||
|
||||
bb23: ; preds = %bb21, %bb19
|
||||
ret void
|
||||
}
|
||||
|
||||
declare i32 @goo()
|
||||
declare i32 @hoo()
|
||||
declare i64 @llvm.expect.i64(i64, i64)
|
||||
|
||||
|
||||
!llvm.ident = !{!0}
|
||||
|
||||
|
||||
!0 = !{!"clang version 5.0.0 (trunk 302965)"}
|
||||
; CHECK: [[WEIGHT]] = !{!"branch_weights", i32 2000, i32 1}
|
||||
; CHECK: [[WEIGHT2]] = !{!"branch_weights", i32 1, i32 2000}
|
@ -1,56 +0,0 @@
|
||||
; RUN: opt -lower-expect -S -o - < %s | FileCheck %s
|
||||
; RUN: opt -S -passes='function(lower-expect)' < %s | FileCheck %s
|
||||
|
||||
; return __builtin_expect((a > b ? 1, goo(), 0);
|
||||
;
|
||||
; Function Attrs: noinline nounwind uwtable
|
||||
define i32 @foo(i32 %arg, i32 %arg1) {
|
||||
; CHECK-LABEL: i32 @foo
|
||||
bb:
|
||||
%tmp5 = icmp sgt i32 %arg, %arg1
|
||||
br i1 %tmp5, label %bb9, label %bb7
|
||||
; CHECK: br i1 %tmp5{{.*}}!prof [[WEIGHT:![0-9]+]]
|
||||
|
||||
bb7: ; preds = %bb
|
||||
%tmp8 = call i32 @goo()
|
||||
br label %bb9
|
||||
|
||||
bb9: ; preds = %bb7, %bb9
|
||||
%tmp10 = phi i32 [ 1, %bb ], [ %tmp8, %bb7 ]
|
||||
%tmp11 = sext i32 %tmp10 to i64
|
||||
%expect = call i64 @llvm.expect.i64(i64 %tmp11, i64 0)
|
||||
%tmp12 = trunc i64 %expect to i32
|
||||
ret i32 %tmp12
|
||||
}
|
||||
|
||||
define i32 @foo2(i32 %arg, i32 %arg1) {
|
||||
bb:
|
||||
%tmp5 = icmp sgt i32 %arg, %arg1
|
||||
br i1 %tmp5, label %bb6, label %bb7
|
||||
; CHECK: br i1 %tmp5{{.*}}!prof [[WEIGHT:![0-9]+]]
|
||||
|
||||
bb6: ; preds = %bb
|
||||
br label %bb9
|
||||
|
||||
bb7: ; preds = %bb
|
||||
%tmp8 = call i32 @goo()
|
||||
br label %bb9
|
||||
|
||||
bb9: ; preds = %bb7, %bb6
|
||||
%tmp10 = phi i32 [ 1, %bb6 ], [ %tmp8, %bb7 ]
|
||||
%tmp11 = sext i32 %tmp10 to i64
|
||||
%expect = call i64 @llvm.expect.i64(i64 %tmp11, i64 0)
|
||||
%tmp12 = trunc i64 %expect to i32
|
||||
ret i32 %tmp12
|
||||
}
|
||||
|
||||
declare i32 @goo()
|
||||
declare i64 @llvm.expect.i64(i64, i64)
|
||||
|
||||
|
||||
|
||||
!llvm.ident = !{!0}
|
||||
|
||||
!0 = !{!"clang version 5.0.0 (trunk 302965)"}
|
||||
|
||||
; CHECK: [[WEIGHT]] = !{!"branch_weights", i32 1, i32 2000}
|
Reference in New Issue
Block a user