[llvm-branch-commits] [BOLT][NFC] Print timers in perf2bolt invocation (PR #101270)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jul 30 17:36:38 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-bolt
Author: Amir Ayupov (aaupov)
<details>
<summary>Changes</summary>
When BOLT is run in AggregateOnly mode (perf2bolt), it exits with code
zero so destructors are not run thus TimerGroup never prints the timers.
Add explicit printing just before the exit to honor options requesting
timers (`--time-rewrite`, `--time-aggr`).
Test Plan: updated bolt/test/timers.c
---
Full diff: https://github.com/llvm/llvm-project/pull/101270.diff
2 Files Affected:
- (modified) bolt/lib/Rewrite/RewriteInstance.cpp (+1)
- (modified) bolt/test/timers.c (+4)
``````````diff
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index b7e361c35088a..9077869fe4955 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -3200,6 +3200,7 @@ void RewriteInstance::processProfileData() {
if (opts::AggregateOnly) {
PrintProgramStats PPS(&*BAT);
BC->logBOLTErrorsAndQuitOnFatal(PPS.runOnFunctions(*BC));
+ TimerGroup::printAll(outs());
exit(0);
}
}
diff --git a/bolt/test/timers.c b/bolt/test/timers.c
index 97dc2506adecd..8d146c321d7f9 100644
--- a/bolt/test/timers.c
+++ b/bolt/test/timers.c
@@ -3,6 +3,9 @@
# RUN: link_fdata %s %t.exe %t.fdata
# RUN: llvm-bolt %t.exe -o %t.null --data %t.fdata -w %t.yaml --time-rewrite \
# RUN: | FileCheck %s
+# RUN: link_fdata %s %t.exe %t.preagg PREAGG
+# RUN: perf2bolt %t.exe -o %t.null -p %t.preagg --pa --time-rewrite \
+# RUN: | FileCheck %s
# CHECK-DAG: update metadata post-emit
# CHECK-DAG: process section metadata
@@ -11,5 +14,6 @@
# CHECK-DAG: finalize metadata pre-emit
# FDATA: 0 [unknown] 0 1 main 0 1 0
+# PREAGG: B X:0 #main# 1 0
*/
int main() { return 0; }
``````````
</details>
https://github.com/llvm/llvm-project/pull/101270
More information about the llvm-branch-commits
mailing list