[llvm] ecff9e3 - [FuncSpec] Fixed minor formatting issues. NFC.

Sjoerd Meijer via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 9 02:37:01 PDT 2021


Author: Sjoerd Meijer
Date: 2021-09-09T10:36:54+01:00
New Revision: ecff9e3da54ec796eb2c58aca1c3047cdcd4560b

URL: https://github.com/llvm/llvm-project/commit/ecff9e3da54ec796eb2c58aca1c3047cdcd4560b
DIFF: https://github.com/llvm/llvm-project/commit/ecff9e3da54ec796eb2c58aca1c3047cdcd4560b.diff

LOG: [FuncSpec] Fixed minor formatting issues. NFC.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp b/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
index 03a318e734765..dbf4000a7f3b3 100644
--- a/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
@@ -22,12 +22,16 @@
 //   and thus control compile-times / code-size.
 //
 // Todos:
-// - Limit the times a recursive function get specialized when
-// `func-specialization-max-iters`
-//   increases linearly. See discussion in https://reviews.llvm.org/D106426 for
-//   details.
+// - Specializing recursive functions relies on running the transformation a
+//   number of times, which is controlled by option
+//   `func-specialization-max-iters`. Thus, increasing this value and the
+//   number of iterations, will linearly increase the number of times recursive
+//   functions get specialized, see also the discussion in
+//   https://reviews.llvm.org/D106426 for details. Perhaps there is a
+//   compile-time friendlier way to control/limit the number of specialisations
+//   for recursive functions.
 // - Don't transform the function if there is no function specialization
-// happens.
+//   happens.
 //
 //===----------------------------------------------------------------------===//
 
@@ -335,9 +339,8 @@ class FunctionSpecializer {
                           SmallVectorImpl<Function *> &Specializations) {
 
     // Do not specialize the cloned function again.
-    if (SpecializedFuncs.contains(F)) {
+    if (SpecializedFuncs.contains(F))
       return false;
-    }
 
     // If we're optimizing the function for size, we shouldn't specialize it.
     if (F->hasOptSize() ||
@@ -664,11 +667,9 @@ class FunctionSpecializer {
 
       auto *V = CS.getArgOperand(A->getArgNo());
       // TrackValueOfGlobalVariable only tracks scalar global variables.
-      if (auto *GV = dyn_cast<GlobalVariable>(V)) {
-        if (!GV->getValueType()->isSingleValueType()) {
+      if (auto *GV = dyn_cast<GlobalVariable>(V))
+        if (!GV->getValueType()->isSingleValueType())
           return false;
-        }
-      }
 
       if (isa<Constant>(V) && (Solver.getLatticeValueFor(V).isConstant() ||
                                EnableSpecializationForLiteralConstant))
@@ -778,9 +779,9 @@ bool llvm::runFunctionSpecialization(
       for (BasicBlock &BB : *F) {
         if (!Solver.isBlockExecutable(&BB))
           continue;
+        // FIXME: The solver may make changes to the function here, so set
+        // Changed, even if later function specialization does not trigger.
         for (auto &I : make_early_inc_range(BB))
-          // FIXME: The solver may make changes to the function here, so set Changed, even if later
-          // function specialization does not trigger.
           Changed |= FS.tryToReplaceWithConstant(&I);
       }
     }
@@ -806,7 +807,7 @@ bool llvm::runFunctionSpecialization(
     // Run the solver for the specialized functions.
     RunSCCPSolver(CurrentSpecializations);
 
-    // Replace some unresolved constant arguments
+    // Replace some unresolved constant arguments.
     constantArgPropagation(FuncDecls, M, Solver);
 
     CurrentSpecializations.clear();


        


More information about the llvm-commits mailing list