[llvm] [FuncSpec] Update function specialization to handle phi-chains (PR #71442)

Alexandros Lamprineas via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 9 04:35:58 PST 2023


================
@@ -809,20 +908,40 @@ bool FunctionSpecializer::findSpecializations(Function *F, unsigned FuncSize,
       auto IsProfitable = [](Bonus &B, unsigned Score, unsigned FuncSize,
                              unsigned FuncGrowth) -> bool {
         // No check required.
-        if (ForceSpecialization)
+        if (ForceSpecialization) {
+          LLVM_DEBUG(dbgs() << "FnSpecialization: Force is on\n");
           return true;
+        }
         // Minimum inlining bonus.
-        if (Score > MinInliningBonus * FuncSize / 100)
+        if (Score > MinInliningBonus * FuncSize / 100) {
+          LLVM_DEBUG(dbgs()
+                     << "FnSpecialization: Sufficient inlining bonus( " << Score
+                     << " > " << MinInliningBonus * FuncSize / 100 << ")\n");
           return true;
+        }
         // Minimum codesize savings.
-        if (B.CodeSize < MinCodeSizeSavings * FuncSize / 100)
+        if (B.CodeSize < MinCodeSizeSavings * FuncSize / 100) {
+          LLVM_DEBUG(dbgs()
+                     << "FnSpecialization: Insufficinet CodeSize Saving("
+                     << B.CodeSize << " > "
+                     << MinCodeSizeSavings * FuncSize / 100 << ")\n");
           return false;
+        }
         // Minimum latency savings.
-        if (B.Latency < MinLatencySavings * FuncSize / 100)
+        if (B.Latency < MinLatencySavings * FuncSize / 100) {
+          LLVM_DEBUG(dbgs()
+                     << "FnSpecialization: Insufficinet Latency Saving("
+                     << B.Latency << " > " << MinLatencySavings * FuncSize / 100
+                     << ")\n");
           return false;
+        }
         // Maximum codesize growth.
-        if (FuncGrowth / FuncSize > MaxCodeSizeGrowth)
+        if (FuncGrowth / FuncSize > MaxCodeSizeGrowth) {
+          LLVM_DEBUG(dbgs() << "FnSpecialization: Func Growth exceeds threshold("
----------------
labrinea wrote:

same here about spacing, also Function growth is more readable, the debug message does not refer to variable names

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


More information about the llvm-commits mailing list