From 3f51bec466c4b67814a7877859ba3eeb5f80da7a Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Wed, 31 Jul 2024 22:14:52 -0700 Subject: [PATCH] [BOLT][NFC] Print timers in perf2bolt invocation 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 Reviewers: ayermolo, maksfb, rafaelauler, dcci Reviewed By: dcci Pull Request: https://github.com/llvm/llvm-project/pull/101270 --- bolt/lib/Rewrite/RewriteInstance.cpp | 1 + bolt/test/timers.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp index b7e361c35088..9077869fe495 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 b16218dd7ea7..a34958a2a15e 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: 2>&1 | 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: 2>&1 | FileCheck %s --check-prefix=CHECK-P2B # CHECK-DAG: update metadata post-emit # CHECK-DAG: process section metadata @@ -10,6 +13,10 @@ # CHECK-DAG: process metadata post-CFG # CHECK-DAG: finalize metadata pre-emit +# CHECK-P2B-DAG: process section metadata +# CHECK-P2B-DAG: process metadata pre-CFG + # FDATA: 0 [unknown] 0 1 main 0 1 0 +# PREAGG: B X:0 #main# 1 0 */ int main() { return 0; }