diff --git a/llvm/include/llvm/Transforms/Utils/SampleProfileInference.h b/llvm/include/llvm/Transforms/Utils/SampleProfileInference.h --- a/llvm/include/llvm/Transforms/Utils/SampleProfileInference.h +++ b/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 &BasicBlocks, - DenseMap &BlockIndex); + FlowFunction + createFlowFunction(const std::vector &BasicBlocks, + DenseMap &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 -void SampleProfileInference::initFunction( - FlowFunction &Func, const std::vector &BasicBlocks, +FlowFunction SampleProfileInference::createFlowFunction( + const std::vector &BasicBlocks, DenseMap &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