llvm.org GIT mirror llvm / 6aa5c26
Add pass printing support to BlockFrequencyInfo pass. The implementation layer already had support for printing the results of this analysis, but the wiring was missing. Now that printing the analysis works, actually bring some of this analysis, and the BranchProbabilityInfo analysis that it wraps, under test! I'm planning on fixing some bugs and doing other work here, so having a nice place to add regression tests and a way to observe the results is really useful. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142491 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 8 years ago
4 changed file(s) with 32 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
3939 void getAnalysisUsage(AnalysisUsage &AU) const;
4040
4141 bool runOnFunction(Function &F);
42 void print(raw_ostream &O, const Module *M) const;
4243
4344 /// getblockFreq - Return block frequency. Return 0 if we don't have the
4445 /// information. Please note that initial frequency is equal to 1024. It means
4848 return false;
4949 }
5050
51 void BlockFrequencyInfo::print(raw_ostream &O, const Module *) const {
52 if (BFI) BFI->print(O);
53 }
54
5155 /// getblockFreq - Return block frequency. Return 0 if we don't have the
5256 /// information. Please note that initial frequency is equal to 1024. It means
5357 /// that we should not rely on the value itself, but only on the comparison to
0 ; RUN: opt < %s -analyze -block-freq | FileCheck %s
1
2 define i32 @test1(i32 %i, i32* %a) {
3 ; CHECK: Printing analysis {{.*}} for function 'test1'
4 ; CHECK: entry = 1024
5 entry:
6 br label %body
7
8 ; Loop backedges are weighted and thus their bodies have a greater frequency.
9 ; CHECK: body = 31744
10 body:
11 %iv = phi i32 [ 0, %entry ], [ %next, %body ]
12 %base = phi i32 [ 0, %entry ], [ %sum, %body ]
13 %arrayidx = getelementptr inbounds i32* %a, i32 %iv
14 %0 = load i32* %arrayidx
15 %sum = add nsw i32 %0, %base
16 %next = add i32 %iv, 1
17 %exitcond = icmp eq i32 %next, %i
18 br i1 %exitcond, label %exit, label %body
19
20 ; CHECK: exit = 1024
21 exit:
22 ret i32 %sum
23 }
0 load_lib llvm.exp
1
2 RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]