[llvm-branch-commits] [BOLT] Drop blocks without profile in BAT YAML (PR #107970)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Sep 9 21:20:43 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-bolt
Author: Amir Ayupov (aaupov)
<details>
<summary>Changes</summary>
Align BAT YAML (DataAggregator) to YAMLProfileWriter which drops blocks
without profile:
https://github.com/llvm/llvm-project/blob/main/bolt/lib/Profile/YAMLProfileWriter.cpp#L162-L176
Test Plan: NFCI
---
Full diff: https://github.com/llvm/llvm-project/pull/107970.diff
1 Files Affected:
- (modified) bolt/lib/Profile/DataAggregator.cpp (+9-5)
``````````diff
diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp
index 10d745cc69824b..4aeeb1daab1b94 100644
--- a/bolt/lib/Profile/DataAggregator.cpp
+++ b/bolt/lib/Profile/DataAggregator.cpp
@@ -2427,11 +2427,15 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
}
}
}
- // Drop blocks without a hash, won't be useful for stale matching.
- llvm::erase_if(YamlBF.Blocks,
- [](const yaml::bolt::BinaryBasicBlockProfile &YamlBB) {
- return YamlBB.Hash == (yaml::Hex64)0;
- });
+ // Skip printing if there's no profile data
+ llvm::erase_if(
+ YamlBF.Blocks, [](const yaml::bolt::BinaryBasicBlockProfile &YamlBB) {
+ auto HasCount = [](const auto &SI) { return SI.Count; };
+ bool HasAnyCount = YamlBB.ExecCount ||
+ llvm::any_of(YamlBB.Successors, HasCount) ||
+ llvm::any_of(YamlBB.CallSites, HasCount);
+ return !HasAnyCount;
+ });
BP.Functions.emplace_back(YamlBF);
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/107970
More information about the llvm-branch-commits
mailing list