This is an archive of the discontinued LLVM Phabricator instance.

[PGO] Dump branch condition type, branch probability and branch hotness as optimization remarks
ClosedPublic

Authored by davidxl on May 31 2017, 4:19 PM.

Details

Summary

This feature is intended to be used to collect branch probability statistics and the statistics can be used to guided the tuning of static branch prediction (which has not been fully tuned).

Sample output from perlbmk:

: eq_i32_Const is true with probability : 0x00000000 / 0x80000000 = 0.00% (total count : 1) [-Rpass-analysis=pgo-use-annot]
: eq_i32_Const is true with probability : 0x00000000 / 0x80000000 = 0.00% (total count : 1) [-Rpass-analysis=pgo-use-annot]
: eq_i32_Const is true with probability : 0x00000000 / 0x80000000 = 0.00% (total count : 1061250) [-Rpass-analysis=pgo-use-annot]
: eq_i32_Const is true with probability : 0x00000000 / 0x80000000 = 0.00% (total count : 11633) [-Rpass-analysis=pgo-use-annot]
: eq_i32_Const is true with probability : 0x00000000 / 0x80000000 = 0.00% (total count : 13537184) [-Rpass-analysis=pgo-use-annot]
: eq_i32_Const is true with probability : 0x00000000 / 0x80000000 = 0.00% (total count : 146) [-Rpass-analysis=pgo-use-annot]
: eq_i32_Const is true with probability : 0x00000000 / 0x80000000 = 0.00% (total count : 1460) [-Rpass-analysis=pgo-use-annot]
: eq_i32_Const is true with probability : 0x00000000 / 0x80000000 = 0.00% (total count : 152) [-Rpass-analysis=pgo-use-annot]
: eq_i32_Const is true with probability : 0x00000000 / 0x80000000 = 0.00% (total count : 154393) [-Rpass-analysis=pgo-use-annot]
: eq_i32_Const is true with probability : 0x00000000 / 0x80000000 = 0.00% (total count : 154627) [-Rpass-analysis=pgo-use-annot]
: eq_i32_Const is true with probability : 0x00000000 / 0x80000000 = 0.00% (total count : 177) [-Rpass-analysis=pgo-use-annot]
: eq_i32_Const is true with probability : 0x00000000 / 0x80000000 = 0.00% (total count : 2) [-Rpass-analysis=pgo-use-annot]
: eq_i32_Const is true with probability : 0x00000000 / 0x80000000 = 0.00% (total count : 2) [-Rpass-analysis=pgo-use-annot]
: eq_i32_Const is true with probability : 0x00000000 / 0x80000000 = 0.00% (total count : 22) [-Rpass-analysis=pgo-use-annot]
: eq_i32_Const is true with probability : 0x00000000 / 0x80000000 = 0.00% (total count : 247756) [-Rpass-analysis=pgo-use-annot]
: eq_i32_Const is true with probability : 0x00000000 / 0x80000000 = 0.00% (total count : 3) [-Rpass-analysis=pgo-use-annot]
: eq_i32_Const is true with probability : 0x00000000 / 0x80000000 = 0.00% (total count : 3) [-Rpass-analysis=pgo-use-a

Diff Detail

Repository
rL LLVM

Event Timeline

davidxl created this revision.May 31 2017, 4:19 PM
danielcdh accepted this revision.Jun 1 2017, 9:25 AM
danielcdh added inline comments.
lib/Transforms/Instrumentation/PGOInstrumentation.cpp
222 ↗(On Diff #100937)

Why not directly output the const int as a number?

This revision is now accepted and ready to land.Jun 1 2017, 9:25 AM
davidxl added inline comments.Jun 1 2017, 9:28 AM
lib/Transforms/Instrumentation/PGOInstrumentation.cpp
222 ↗(On Diff #100937)

The dump is used to collect data for static prediction tuning. Only special values like 0,1,-1 are of interest to the predictor. All other constants only need to be aggregated.

This revision was automatically updated to reflect the committed changes.