[PATCH] D104102: Function Specialisation, cont'd

Sjoerd Meijer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 11 07:06:10 PDT 2021


SjoerdMeijer updated this revision to Diff 351438.
SjoerdMeijer added a comment.

The wrong location didn't sit right, so I have precommitted that in  rG9907746f5db7 <https://reviews.llvm.org/rG9907746f5db7c2a91917fa7b312136f7bf03d2f5> before I continue with the rest and this is a little rebase on top of that.


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

https://reviews.llvm.org/D104102

Files:
  llvm/lib/Transforms/IPO/FunctionSpecialization.cpp


Index: llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
===================================================================
--- llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
+++ llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
@@ -120,6 +120,8 @@
           LLVM_DEBUG(dbgs() << "FnSpecialization: Replaced constant argument: "
                             << Arg.getName() << "\n");
     }
+
+    NumFuncSpecialized += FunctionsSpecialized;
     return Changed;
   }
 
@@ -141,6 +143,8 @@
   }
 
 private:
+  int FunctionsSpecialized = 0;
+
   /// This function decides whether to specialize function \p F based on the
   /// known constant values its arguments can take on. Specialization is
   /// performed on the first interesting argument. Specializations based on
@@ -217,7 +221,7 @@
 
         // Mark all the specialized functions
         Specializations.push_back(Clone);
-        NumFuncSpecialized++;
+        FunctionsSpecialized++;
       }
 
       // TODO: if we want to support specialize specialized functions, and if
@@ -247,7 +251,7 @@
 
     // Otherwise, set the specialization cost to be the cost of all the
     // instructions in the function and penalty for specializing more functions.
-    unsigned Penalty = NumFuncSpecialized + 1;
+    unsigned Penalty = FunctionsSpecialized + 1;
     return Metrics.NumInsts * InlineConstants::InstrCost * Penalty;
   }
 
@@ -631,6 +635,5 @@
 
   // Clean up the IR by removing ssa_copy intrinsics.
   cleanup(M);
-
   return Changed;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104102.351438.patch
Type: text/x-patch
Size: 1513 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210611/db76b7e7/attachment.bin>


More information about the llvm-commits mailing list