[llvm] c6d8b51 - [profi][NFC] Refactor SampleProfileInference::initFunction
Amir Ayupov via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 9 12:41:19 PDT 2023
Author: Amir Ayupov
Date: 2023-06-09T12:41:12-07:00
New Revision: c6d8b51ba5da7530332815a545c72ebd54fca7f6
URL: https://github.com/llvm/llvm-project/commit/c6d8b51ba5da7530332815a545c72ebd54fca7f6
DIFF: https://github.com/llvm/llvm-project/commit/c6d8b51ba5da7530332815a545c72ebd54fca7f6.diff
LOG: [profi][NFC] Refactor SampleProfileInference::initFunction
Initialize and return `FlowFunction` from initFunction->createFlowFunction.
Aligns the interface to `createFlowFunction` in D144500, intent to reuse
in a follow-up.
Reviewed By: spupyrev
Differential Revision: https://reviews.llvm.org/D152216
Added:
Modified:
llvm/include/llvm/Transforms/Utils/SampleProfileInference.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/Utils/SampleProfileInference.h b/llvm/include/llvm/Transforms/Utils/SampleProfileInference.h
index ea7ae0f57b796..e9bc3d18bdcbf 100644
--- a/llvm/include/llvm/Transforms/Utils/SampleProfileInference.h
+++ b/llvm/include/llvm/Transforms/Utils/SampleProfileInference.h
@@ -136,9 +136,9 @@ template <typename FT> class SampleProfileInference {
private:
/// Initialize flow function blocks, jumps and misc metadata.
- void initFunction(FlowFunction &Func,
- const std::vector<const BasicBlockT *> &BasicBlocks,
- DenseMap<const BasicBlockT *, uint64_t> &BlockIndex);
+ FlowFunction
+ createFlowFunction(const std::vector<const BasicBlockT *> &BasicBlocks,
+ DenseMap<const BasicBlockT *, uint64_t> &BlockIndex);
/// Try to infer branch probabilities mimicking implementation of
/// BranchProbabilityInfo. Unlikely taken branches are marked so that the
@@ -207,8 +207,7 @@ void SampleProfileInference<BT>::apply(BlockWeightMap &BlockWeights,
}
// Create necessary objects
- FlowFunction Func;
- initFunction(Func, BasicBlocks, BlockIndex);
+ FlowFunction Func = createFlowFunction(BasicBlocks, BlockIndex);
// Create and apply the inference network model.
applyFlowInference(Func);
@@ -240,9 +239,10 @@ void SampleProfileInference<BT>::apply(BlockWeightMap &BlockWeights,
}
template <typename BT>
-void SampleProfileInference<BT>::initFunction(
- FlowFunction &Func, const std::vector<const BasicBlockT *> &BasicBlocks,
+FlowFunction SampleProfileInference<BT>::createFlowFunction(
+ const std::vector<const BasicBlockT *> &BasicBlocks,
DenseMap<const BasicBlockT *, uint64_t> &BlockIndex) {
+ FlowFunction Func;
Func.Blocks.reserve(BasicBlocks.size());
// Create FlowBlocks
for (const auto *BB : BasicBlocks) {
@@ -293,6 +293,8 @@ void SampleProfileInference<BT>::initFunction(
EntryBlock.Weight = 1;
EntryBlock.HasUnknownWeight = false;
}
+
+ return Func;
}
template <typename BT>
More information about the llvm-commits
mailing list