Skip to content

Commit 40f0581

Browse files
committed
[ctx_prof] Flattened profile lowering pass
1 parent 53b11dd commit 40f0581

File tree

9 files changed

+497
-3
lines changed

9 files changed

+497
-3
lines changed

llvm/include/llvm/ProfileData/ProfileCommon.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ class ProfileSummaryBuilder {
7979
class InstrProfSummaryBuilder final : public ProfileSummaryBuilder {
8080
uint64_t MaxInternalBlockCount = 0;
8181

82-
inline void addEntryCount(uint64_t Count);
83-
inline void addInternalCount(uint64_t Count);
84-
8582
public:
8683
InstrProfSummaryBuilder(std::vector<uint32_t> Cutoffs)
8784
: ProfileSummaryBuilder(std::move(Cutoffs)) {}
8885

86+
void addEntryCount(uint64_t Count);
87+
void addInternalCount(uint64_t Count);
88+
8989
void addRecord(const InstrProfRecord &);
9090
std::unique_ptr<ProfileSummary> getSummary();
9191
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//===-- PGOCtxProfFlattening.h - Contextual Instr. Flattening ---*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file declares the PGOCtxProfFlattening class.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_PGOCTXPROFFLATTENING_H
13+
#define LLVM_TRANSFORMS_INSTRUMENTATION_PGOCTXPROFFLATTENING_H
14+
15+
#include "llvm/IR/PassManager.h"
16+
namespace llvm {
17+
18+
class PGOCtxProfFlatteningPass
19+
: public PassInfoMixin<PGOCtxProfFlatteningPass> {
20+
public:
21+
explicit PGOCtxProfFlatteningPass() = default;
22+
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
23+
};
24+
} // namespace llvm
25+
#endif

llvm/lib/Passes/PassBuilder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@
198198
#include "llvm/Transforms/Instrumentation/MemProfiler.h"
199199
#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
200200
#include "llvm/Transforms/Instrumentation/NumericalStabilitySanitizer.h"
201+
#include "llvm/Transforms/Instrumentation/PGOCtxProfFlattening.h"
201202
#include "llvm/Transforms/Instrumentation/PGOCtxProfLowering.h"
202203
#include "llvm/Transforms/Instrumentation/PGOForceFunctionAttrs.h"
203204
#include "llvm/Transforms/Instrumentation/PGOInstrumentation.h"

llvm/lib/Passes/PassBuilderPipelines.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
#include "llvm/Transforms/Instrumentation/InstrOrderFile.h"
7777
#include "llvm/Transforms/Instrumentation/InstrProfiling.h"
7878
#include "llvm/Transforms/Instrumentation/MemProfiler.h"
79+
#include "llvm/Transforms/Instrumentation/PGOCtxProfFlattening.h"
7980
#include "llvm/Transforms/Instrumentation/PGOCtxProfLowering.h"
8081
#include "llvm/Transforms/Instrumentation/PGOForceFunctionAttrs.h"
8182
#include "llvm/Transforms/Instrumentation/PGOInstrumentation.h"

llvm/lib/Passes/PassRegistry.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ MODULE_PASS("coro-early", CoroEarlyPass())
5858
MODULE_PASS("cross-dso-cfi", CrossDSOCFIPass())
5959
MODULE_PASS("ctx-instr-gen",
6060
PGOInstrumentationGen(PGOInstrumentationType::CTXPROF))
61+
MODULE_PASS("ctx-prof-flatten", PGOCtxProfFlatteningPass())
6162
MODULE_PASS("deadargelim", DeadArgumentEliminationPass())
6263
MODULE_PASS("debugify", NewPMDebugifyPass())
6364
MODULE_PASS("dfsan", DataFlowSanitizerPass())

llvm/lib/Transforms/Instrumentation/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ add_llvm_component_library(LLVMInstrumentation
1515
InstrProfiling.cpp
1616
KCFI.cpp
1717
LowerAllowCheckPass.cpp
18+
PGOCtxProfFlattening.cpp
1819
PGOCtxProfLowering.cpp
1920
PGOForceFunctionAttrs.cpp
2021
PGOInstrumentation.cpp

0 commit comments

Comments
 (0)