[llvm] [TRE] Adjust function entry count when using instrumented profiles (PR #143987)

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 19 07:50:01 PDT 2025


================
@@ -428,8 +438,20 @@ class TailRecursionEliminator {
 
   TailRecursionEliminator(Function &F, const TargetTransformInfo *TTI,
                           AliasAnalysis *AA, OptimizationRemarkEmitter *ORE,
-                          DomTreeUpdater &DTU)
-      : F(F), TTI(TTI), AA(AA), ORE(ORE), DTU(DTU) {}
+                          DomTreeUpdater &DTU, BlockFrequencyInfo *BFI)
+      : F(F), TTI(TTI), AA(AA), ORE(ORE), DTU(DTU), BFI(BFI),
+        OrigEntryBBFreq(
+            BFI ? BFI->getBlockFreq(&F.getEntryBlock()).getFrequency() : 0U) {
+    if (BFI) {
+      auto EC = F.getEntryCount();
+      (void)EC;
+      assert(
+          (EC.has_value() && EC->getCount() != 0 && OrigEntryBBFreq) &&
+          "If the function has an entry count, its entry basic block should "
----------------
mtrofin wrote:

fixed.

https://github.com/llvm/llvm-project/pull/143987


More information about the llvm-commits mailing list