[PATCH] D152216: [profi][NFC] Refactor SampleProfileInference::initFunction

Amir Ayupov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 9 12:41:21 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc6d8b51ba5da: [profi][NFC] Refactor SampleProfileInference::initFunction (authored by Amir).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152216/new/

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.530055.patch
Type: text/x-patch
Size: 1772 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230609/ae766ee5/attachment.bin>


More information about the llvm-commits mailing list