[llvm] [MergeFunctions] Preserve instruction-level profile metadata during merging (PR #208009)
Alok Kumar Sharma via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 9 23:58:02 PDT 2026
================
@@ -305,20 +329,36 @@ class MergeFunctions {
/// Deleted-New functions mapping
DenseMap<Function *, Function *> DelToNewMap;
+
+ FunctionAnalysisManager *FAM = nullptr;
+
+ struct CachedProfileAnalyses {
+ DominatorTree DT;
+ LoopInfo LI;
+ BranchProbabilityInfo BPI;
+ BlockFrequencyInfo BFI;
+
+ CachedProfileAnalyses(Function &F)
+ : DT(F), LI(DT), BPI(F, LI, nullptr, &DT), BFI(F, BPI, LI) {}
+ };
+ DenseMap<const Function *, std::unique_ptr<CachedProfileAnalyses>> CachedBFI;
----------------
alokkrsharma wrote:
It was there to support the no-FAM path used by MergeFunctionsTest.cpp (runOnModule / runOnFunctions called without FAM). I wanted block-level scaling to still work there.
But those tests don't use !prof metadata, and we already fall back to entry-count scaling without BFI, so this isn't buying us much. I'll remove it in the next revision.
https://github.com/llvm/llvm-project/pull/208009
More information about the llvm-commits
mailing list