~ubuntu-branches/ubuntu/quantal/llvm-3.1/quantal

« back to all changes in this revision

Viewing changes to test/Analysis/BranchProbabilityInfo/noreturn.ll

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2012-03-29 19:09:51 UTC
  • Revision ID: package-import@ubuntu.com-20120329190951-aq83ivog4cg8bxun
Tags: upstream-3.1~svn153643
ImportĀ upstreamĀ versionĀ 3.1~svn153643

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
; Test the static branch probability heuristics for no-return functions.
 
2
; RUN: opt < %s -analyze -branch-prob | FileCheck %s
 
3
 
 
4
declare void @abort() noreturn
 
5
 
 
6
define i32 @test1(i32 %a, i32 %b) {
 
7
; CHECK: Printing analysis {{.*}} for function 'test1'
 
8
entry:
 
9
  %cond = icmp eq i32 %a, 42
 
10
  br i1 %cond, label %exit, label %abort
 
11
; CHECK: edge entry -> exit probability is 1048575 / 1048576
 
12
; CHECK: edge entry -> abort probability is 1 / 1048576
 
13
 
 
14
abort:
 
15
  call void @abort() noreturn
 
16
  unreachable
 
17
 
 
18
exit:
 
19
  ret i32 %b
 
20
}
 
21
 
 
22
define i32 @test2(i32 %a, i32 %b) {
 
23
; CHECK: Printing analysis {{.*}} for function 'test2'
 
24
entry:
 
25
  switch i32 %a, label %exit [i32 1, label %case_a
 
26
                              i32 2, label %case_b
 
27
                              i32 3, label %case_c
 
28
                              i32 4, label %case_d]
 
29
; CHECK: edge entry -> exit probability is 1048575 / 1048579
 
30
; CHECK: edge entry -> case_a probability is 1 / 1048579
 
31
; CHECK: edge entry -> case_b probability is 1 / 1048579
 
32
; CHECK: edge entry -> case_c probability is 1 / 1048579
 
33
; CHECK: edge entry -> case_d probability is 1 / 1048579
 
34
 
 
35
case_a:
 
36
  br label %case_b
 
37
 
 
38
case_b:
 
39
  br label %case_c
 
40
 
 
41
case_c:
 
42
  br label %case_d
 
43
 
 
44
case_d:
 
45
  call void @abort() noreturn
 
46
  unreachable
 
47
 
 
48
exit:
 
49
  ret i32 %b
 
50
}
 
51
 
 
52
define i32 @test3(i32 %a, i32 %b) {
 
53
; CHECK: Printing analysis {{.*}} for function 'test3'
 
54
; Make sure we unify across multiple conditional branches.
 
55
entry:
 
56
  %cond1 = icmp eq i32 %a, 42
 
57
  br i1 %cond1, label %exit, label %dom
 
58
; CHECK: edge entry -> exit probability is 1048575 / 1048576
 
59
; CHECK: edge entry -> dom probability is 1 / 1048576
 
60
 
 
61
dom:
 
62
  %cond2 = icmp ult i32 %a, 42
 
63
  br i1 %cond2, label %idom1, label %idom2
 
64
; CHECK: edge dom -> idom1 probability is 1 / 2
 
65
; CHECK: edge dom -> idom2 probability is 1 / 2
 
66
 
 
67
idom1:
 
68
  br label %abort
 
69
 
 
70
idom2:
 
71
  br label %abort
 
72
 
 
73
abort:
 
74
  call void @abort() noreturn
 
75
  unreachable
 
76
 
 
77
exit:
 
78
  ret i32 %b
 
79
}