Skip to content

Commit

Permalink
[BOLT][NFC] Add timers for MetadataManager invocations
Browse files Browse the repository at this point in the history
Test Plan: added bolt/test/timers.c

Reviewers: ayermolo, maksfb, rafaelauler, dcci

Reviewed By: dcci

Pull Request: llvm#101267
  • Loading branch information
aaupov authored Aug 1, 2024
1 parent 991a621 commit fb97b4f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bolt/lib/Rewrite/RewriteInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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) {
Expand Down
15 changes: 15 additions & 0 deletions bolt/test/timers.c
Original file line number Diff line number Diff line change
@@ -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: 2>&1 | 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; }

0 comments on commit fb97b4f

Please sign in to comment.