[PATCH] D152216: [profi][NFC] Refactor SampleProfileInference::initFunction
Amir Ayupov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 5 17:26:51 PDT 2023
Amir created this revision.
Amir added a reviewer: spupyrev.
Herald added a subscriber: wenlei.
Herald added a project: All.
Amir requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Initialize and return `FlowFunction` from initFunction->createFlowFunction.
Aligns the interface to `createFlowFunction` in D144500 <https://reviews.llvm.org/D144500>, intent to reuse
in a follow-up.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D152216
Files:
llvm/include/llvm/Transforms/Utils/SampleProfileInference.h
Index: llvm/include/llvm/Transforms/Utils/SampleProfileInference.h
===================================================================
--- llvm/include/llvm/Transforms/Utils/SampleProfileInference.h
+++ llvm/include/llvm/Transforms/Utils/SampleProfileInference.h
@@ -136,9 +136,9 @@
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 @@
}
// 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 @@
}
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 @@
EntryBlock.Weight = 1;
EntryBlock.HasUnknownWeight = false;
}
+
+ return Func;
}
template <typename BT>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152216.528642.patch
Type: text/x-patch
Size: 1772 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230606/d5f56e78/attachment.bin>
More information about the llvm-commits
mailing list