summaryrefslogtreecommitdiffstats
path: root/llvm/test/Analysis
diff options
context:
space:
mode:
authorTaewook Oh <taewook.oh@gmail.com>2019-12-02 10:15:22 -0800
committerTaewook Oh <taewook.oh@gmail.com>2019-12-02 10:28:40 -0800
commit2da205d43eeb402d2c42bdbd2f564e2686b5573d (patch)
tree81dfdcfa2abac6d5178f6e65b5c374ef3d9c77c6 /llvm/test/Analysis
parentfe459ce65a993dee5e20648a8e01330a44e879b8 (diff)
downloadbcm5719-llvm-2da205d43eeb402d2c42bdbd2f564e2686b5573d.tar.gz
bcm5719-llvm-2da205d43eeb402d2c42bdbd2f564e2686b5573d.zip
Reland "b19ec1eb3d0c [BPI] Improve unreachable/ColdCall heurstics to handle loops."
Summary: b19ec1eb3d0c has been reverted because of the test failures with PowerPC targets. This patch addresses the issues from the previous commit. Test Plan: ninja check-all. Confirmed that CodeGen/PowerPC/pr36292.ll and CodeGen/PowerPC/sms-cpy-1.ll pass Subscribers: llvm-commits
Diffstat (limited to 'llvm/test/Analysis')
-rw-r--r--llvm/test/Analysis/BranchProbabilityInfo/basic.ll18
-rw-r--r--llvm/test/Analysis/BranchProbabilityInfo/noreturn.ll26
2 files changed, 44 insertions, 0 deletions
diff --git a/llvm/test/Analysis/BranchProbabilityInfo/basic.ll b/llvm/test/Analysis/BranchProbabilityInfo/basic.ll
index 64e0a82456f..8212cc47690 100644
--- a/llvm/test/Analysis/BranchProbabilityInfo/basic.ll
+++ b/llvm/test/Analysis/BranchProbabilityInfo/basic.ll
@@ -141,6 +141,24 @@ exit:
ret i32 %result
}
+define i32 @test_cold_loop(i32 %a, i32 %b) {
+entry:
+ %cond1 = icmp eq i32 %a, 42
+ br i1 %cond1, label %header, label %exit
+
+header:
+ br label %body
+
+body:
+ %cond2 = icmp eq i32 %b, 42
+ br i1 %cond2, label %header, label %exit
+; CHECK: edge body -> header probability is 0x40000000 / 0x80000000 = 50.00%
+
+exit:
+ call void @coldfunc()
+ ret i32 %b
+}
+
declare i32 @regular_function(i32 %i)
define i32 @test_cold_call_sites_with_prof(i32 %a, i32 %b, i1 %flag, i1 %flag2) {
diff --git a/llvm/test/Analysis/BranchProbabilityInfo/noreturn.ll b/llvm/test/Analysis/BranchProbabilityInfo/noreturn.ll
index 0566ca16c2f..6e01afd2cfc 100644
--- a/llvm/test/Analysis/BranchProbabilityInfo/noreturn.ll
+++ b/llvm/test/Analysis/BranchProbabilityInfo/noreturn.ll
@@ -79,6 +79,32 @@ exit:
ret i32 %b
}
+define i32 @test4(i32 %a, i32 %b) {
+; CHECK: Printing analysis {{.*}} for function 'test4'
+; Make sure we handle loops post-dominated by unreachables.
+entry:
+ %cond1 = icmp eq i32 %a, 42
+ br i1 %cond1, label %header, label %exit
+; CHECK: edge entry -> header probability is 0x00000001 / 0x80000000 = 0.00%
+; CHECK: edge entry -> exit probability is 0x7fffffff / 0x80000000 = 100.00% [HOT edge]
+
+header:
+ br label %body
+
+body:
+ %cond2 = icmp eq i32 %a, 42
+ br i1 %cond2, label %header, label %abort
+; CHECK: edge body -> header probability is 0x40000000 / 0x80000000 = 50.00%
+; CHECK: edge body -> abort probability is 0x40000000 / 0x80000000 = 50.00%
+
+abort:
+ call void @abort() noreturn
+ unreachable
+
+exit:
+ ret i32 %b
+}
+
@_ZTIi = external global i8*
; CHECK-LABEL: throwSmallException
OpenPOWER on IntegriCloud