[llvm] [BOLT][NFC] Add timers for MetadataManager invocations (PR #101267)
Amir Ayupov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 31 16:39:33 PDT 2024
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/101267
>From d8d9a82b5e89dc6e3df21c53ae11984d3909cf5f Mon Sep 17 00:00:00 2001
From: Amir Ayupov <aaupov at fb.com>
Date: Tue, 30 Jul 2024 17:32:34 -0700
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
=?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.4
---
bolt/lib/Rewrite/RewriteInstance.cpp | 10 ++++++++++
bolt/test/timers.c | 15 +++++++++++++++
2 files changed, 25 insertions(+)
create mode 100644 bolt/test/timers.c
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 33ebae3b6e6de..b7e361c35088a 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -3131,18 +3131,24 @@ void RewriteInstance::initializeMetadataManager() {
}
void RewriteInstance::processSectionMetadata() {
+ NamedRegionTimer T("processmetadata-section", "process section metadata",
+ TimerGroupName, TimerGroupDesc, opts::TimeRewrite);
initializeMetadataManager();
MetadataManager.runSectionInitializers();
}
void RewriteInstance::processMetadataPreCFG() {
+ NamedRegionTimer T("processmetadata-precfg", "process metadata pre-CFG",
+ TimerGroupName, TimerGroupDesc, opts::TimeRewrite);
MetadataManager.runInitializersPreCFG();
processProfileDataPreCFG();
}
void RewriteInstance::processMetadataPostCFG() {
+ NamedRegionTimer T("processmetadata-postcfg", "process metadata post-CFG",
+ TimerGroupName, TimerGroupDesc, opts::TimeRewrite);
MetadataManager.runInitializersPostCFG();
}
@@ -3536,10 +3542,14 @@ void RewriteInstance::emitAndLink() {
}
void RewriteInstance::finalizeMetadataPreEmit() {
+ NamedRegionTimer T("finalizemetadata-preemit", "finalize metadata pre-emit",
+ TimerGroupName, TimerGroupDesc, opts::TimeRewrite);
MetadataManager.runFinalizersPreEmit();
}
void RewriteInstance::updateMetadata() {
+ NamedRegionTimer T("updatemetadata-postemit", "update metadata post-emit",
+ TimerGroupName, TimerGroupDesc, opts::TimeRewrite);
MetadataManager.runFinalizersAfterEmit();
if (opts::UpdateDebugSections) {
diff --git a/bolt/test/timers.c b/bolt/test/timers.c
new file mode 100644
index 0000000000000..97dc2506adecd
--- /dev/null
+++ b/bolt/test/timers.c
@@ -0,0 +1,15 @@
+/* This test checks timers for metadata manager phases.
+# RUN: %clang %cflags %s -o %t.exe
+# 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
+
+# CHECK-DAG: update metadata post-emit
+# CHECK-DAG: process section metadata
+# CHECK-DAG: process metadata pre-CFG
+# CHECK-DAG: process metadata post-CFG
+# CHECK-DAG: finalize metadata pre-emit
+
+# FDATA: 0 [unknown] 0 1 main 0 1 0
+*/
+int main() { return 0; }
>From 8432b418c63fe1a91dd891623c226b5e616616dc Mon Sep 17 00:00:00 2001
From: Amir Ayupov <aaupov at fb.com>
Date: Wed, 31 Jul 2024 16:39:23 -0700
Subject: [PATCH 2/2] Fix test
Created using spr 1.3.4
---
bolt/test/timers.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bolt/test/timers.c b/bolt/test/timers.c
index 97dc2506adecd..b16218dd7ea76 100644
--- a/bolt/test/timers.c
+++ b/bolt/test/timers.c
@@ -2,7 +2,7 @@
# RUN: %clang %cflags %s -o %t.exe
# 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: 2>&1 | FileCheck %s
# CHECK-DAG: update metadata post-emit
# CHECK-DAG: process section metadata
More information about the llvm-commits
mailing list