summaryrefslogtreecommitdiff
path: root/bolt
diff options
context:
space:
mode:
Diffstat (limited to 'bolt')
-rw-r--r--bolt/include/bolt/Core/BinaryFunction.h4
-rw-r--r--bolt/lib/Core/BinaryFunction.cpp1
-rw-r--r--bolt/lib/Profile/YAMLProfileReader.cpp6
-rw-r--r--bolt/test/X86/branch-data.test7
4 files changed, 15 insertions, 3 deletions
diff --git a/bolt/include/bolt/Core/BinaryFunction.h b/bolt/include/bolt/Core/BinaryFunction.h
index 7a99ce2481a1..a96243c579eb 100644
--- a/bolt/include/bolt/Core/BinaryFunction.h
+++ b/bolt/include/bolt/Core/BinaryFunction.h
@@ -1794,6 +1794,10 @@ public:
/// executions corresponding to this function.
uint64_t getRawBranchCount() const { return RawBranchCount; }
+ /// Set the profile data about the number of branch executions corresponding
+ /// to this function.
+ void setRawBranchCount(uint64_t Count) { RawBranchCount = Count; }
+
/// Return the execution count for functions with known profile.
/// Return 0 if the function has no profile.
uint64_t getKnownExecutionCount() const {
diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp
index 1cbdd6b2721b..69ebd12bd0db 100644
--- a/bolt/lib/Core/BinaryFunction.cpp
+++ b/bolt/lib/Core/BinaryFunction.cpp
@@ -470,6 +470,7 @@ void BinaryFunction::print(raw_ostream &OS, std::string Annotation) {
OS << "\n Image : 0x" << Twine::utohexstr(getImageAddress());
if (ExecutionCount != COUNT_NO_PROFILE) {
OS << "\n Exec Count : " << ExecutionCount;
+ OS << "\n Branch Count: " << RawBranchCount;
OS << "\n Profile Acc : " << format("%.1f%%", ProfileMatchRatio * 100.0f);
}
diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp
index 13f56ed51c3a..0e4ab57984d5 100644
--- a/bolt/lib/Profile/YAMLProfileReader.cpp
+++ b/bolt/lib/Profile/YAMLProfileReader.cpp
@@ -83,6 +83,12 @@ bool YAMLProfileReader::parseFunctionProfile(
BF.setExecutionCount(YamlBF.ExecCount);
+ uint64_t FuncRawBranchCount = 0;
+ for (const yaml::bolt::BinaryBasicBlockProfile &YamlBB : YamlBF.Blocks)
+ for (const yaml::bolt::SuccessorInfo &YamlSI : YamlBB.Successors)
+ FuncRawBranchCount += YamlSI.Count;
+ BF.setRawBranchCount(FuncRawBranchCount);
+
if (!opts::IgnoreHash && YamlBF.Hash != BF.computeHash(/*UseDFS=*/true)) {
if (opts::Verbosity >= 1)
errs() << "BOLT-WARNING: function hash mismatch\n";
diff --git a/bolt/test/X86/branch-data.test b/bolt/test/X86/branch-data.test
index 24f90f2d8f5e..5d6ff92d18e2 100644
--- a/bolt/test/X86/branch-data.test
+++ b/bolt/test/X86/branch-data.test
@@ -3,18 +3,19 @@
# Also checks that llvm-bolt disassembler and CFG builder is working properly.
RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe
-RUN: llvm-bolt %t.exe -o /dev/null --data %p/Inputs/blarge.fdata --print-cfg
+RUN: llvm-bolt %t.exe -o /dev/null --data %p/Inputs/blarge.fdata --print-cfg | FileCheck %s
CHECK: Binary Function "usqrt"
CHECK: State : CFG constructed
CHECK: Address : 0x401170
CHECK: Size : 0x43
-CHECK: MaxSize : 0x50
-CHECK: Offset : 0x1170
+CHECK: MaxSize : 0x43
+CHECK: Offset : 0xcb0
CHECK: Section : .text
CHECK: IsSimple : 1
CHECK: BB Count : 5
CHECK: Exec Count : 199
+CHECK: Branch Count: 7689
CHECK: }
CHECK: .LBB{{.*}}
CHECK: Exec Count : 199