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; }