[llvm] [BOLT][NFC] Add timers for MetadataManager invocations (PR #101267)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 30 17:33:19 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-bolt

Author: Amir Ayupov (aaupov)

<details>
<summary>Changes</summary>



Test Plan: added bolt/test/timers.c


---
Full diff: https://github.com/llvm/llvm-project/pull/101267.diff


2 Files Affected:

- (modified) bolt/lib/Rewrite/RewriteInstance.cpp (+10) 
- (added) bolt/test/timers.c (+15) 


``````````diff
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; }

``````````

</details>


https://github.com/llvm/llvm-project/pull/101267


More information about the llvm-commits mailing list