Index: include/llvm/Analysis/InlineCost.h =================================================================== --- include/llvm/Analysis/InlineCost.h +++ include/llvm/Analysis/InlineCost.h @@ -29,13 +29,13 @@ namespace InlineConstants { // Various thresholds used by inline cost analysis. -// Use when optsize (-Os) is specified. +/// Use when optsize (-Os) is specified. const int OptSizeThreshold = 75; -// Use when minsize (-Oz) is specified. +/// Use when minsize (-Oz) is specified. const int OptMinSizeThreshold = 25; -// Use when -O3 is specified. +/// Use when -O3 is specified. const int OptAggressiveThreshold = 275; // Various magic constants used to adjust heuristics. Index: include/llvm/IR/Function.h =================================================================== --- include/llvm/IR/Function.h +++ include/llvm/IR/Function.h @@ -110,11 +110,12 @@ ~Function() override; - /// \brief Provide fast operand accessors + // Provide fast operand accessors. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); - - Type *getReturnType() const; // Return the type of the ret val - FunctionType *getFunctionType() const; // Return the FunctionType for me + /// Returns the type of the ret val. + Type *getReturnType() const; + /// Returns the FunctionType for me. + FunctionType *getFunctionType() const; /// getContext - Return a reference to the LLVMContext associated with this /// function. @@ -190,10 +191,14 @@ getContext(), AttributeSet::FunctionIndex, Kind)); } - /// Set the entry count for this function. + /// \breif Set the entry count for this function. + /// Entry cound is the number of times function have been executed based on + /// pgo data. void setEntryCount(uint64_t Count); - /// Get the entry count for this function. + /// \brief Get the entry count for this function. + /// Entry cout is the number of times function have been executed based on + /// pgo data. Optional getEntryCount() const; /// @brief Return true if the function has the attribute. @@ -324,7 +329,7 @@ } /// @brief Determine if the function may only access memory that is - // either inaccessible from the IR or pointed to by its arguments. + /// either inaccessible from the IR or pointed to by its arguments. bool onlyAccessesInaccessibleMemOrArgMem() const { return hasFnAttribute(Attribute::InaccessibleMemOrArgMemOnly); } @@ -647,8 +652,8 @@ void allocHungoffUselist(); template void setHungoffOperand(Constant *C); - // Shadow Value::setValueSubclassData with a private forwarding method so that - // subclasses cannot accidentally use it. + /// Shadow Value::setValueSubclassData with a private forwarding method so + /// that subclasses cannot accidentally use it. void setValueSubclassData(unsigned short D) { Value::setValueSubclassData(D); } Index: include/llvm/ProfileData/ProfileCommon.h =================================================================== --- include/llvm/ProfileData/ProfileCommon.h +++ include/llvm/ProfileData/ProfileCommon.h @@ -45,22 +45,21 @@ class ProfileSummaryBuilder { private: - // We keep track of the number of times a count (block count or samples) - // appears in the profile. The map is kept sorted in the descending order of - // counts. + /// We keep track of the number of times a count (block count or samples) + /// appears in the profile. The map is kept sorted in the descending order of + /// counts. std::map> CountFrequencies; std::vector DetailedSummaryCutoffs; protected: SummaryEntryVector DetailedSummary; ProfileSummaryBuilder(std::vector Cutoffs) - : DetailedSummaryCutoffs(std::move(Cutoffs)), TotalCount(0), MaxCount(0), - MaxFunctionCount(0), NumCounts(0), NumFunctions(0) {} + : DetailedSummaryCutoffs(std::move(Cutoffs)) {} inline void addCount(uint64_t Count); ~ProfileSummaryBuilder() = default; void computeDetailedSummary(); - uint64_t TotalCount, MaxCount, MaxFunctionCount; - uint32_t NumCounts, NumFunctions; + uint64_t TotalCount = 0, MaxCount = 0, MaxFunctionCount = 0; + uint32_t NumCounts = 0, NumFunctions = 0; public: /// \brief A vector of useful cutoff values for detailed summary. @@ -68,13 +67,13 @@ }; class InstrProfSummaryBuilder final : public ProfileSummaryBuilder { - uint64_t MaxInternalBlockCount; + uint64_t MaxInternalBlockCount = 0; inline void addEntryCount(uint64_t Count); inline void addInternalCount(uint64_t Count); public: InstrProfSummaryBuilder(std::vector Cutoffs) - : ProfileSummaryBuilder(std::move(Cutoffs)), MaxInternalBlockCount(0) {} + : ProfileSummaryBuilder(std::move(Cutoffs)) {} void addRecord(const InstrProfRecord &); std::unique_ptr getSummary(); }; @@ -88,7 +87,7 @@ std::unique_ptr getSummary(); }; -// This is called when a count is seen in the profile. +/// This is called when a count is seen in the profile. void ProfileSummaryBuilder::addCount(uint64_t Count) { TotalCount += Count; if (Count > MaxCount) Index: lib/Analysis/InlineCost.cpp =================================================================== --- lib/Analysis/InlineCost.cpp +++ lib/Analysis/InlineCost.cpp @@ -75,15 +75,15 @@ /// Profile summary information. ProfileSummaryInfo *PSI; - // The called function. + /// The called function. Function &F; - // The candidate callsite being analyzed. Please do not use this to do - // analysis in the caller function; we want the inline cost query to be - // easily cacheable. Instead, use the cover function paramHasAttr. + /// The candidate callsite being analyzed. Please do not use this to do + /// analysis in the caller function; we want the inline cost query to be + /// easily cacheable. Instead, use the cover function paramHasAttr. CallSite CandidateCS; - // Tunable parameters that control the analysis. + /// Tunable parameters that control the analysis. const InlineParams &Params; int Threshold; @@ -104,25 +104,25 @@ int FiftyPercentVectorBonus, TenPercentVectorBonus; int VectorBonus; - // While we walk the potentially-inlined instructions, we build up and - // maintain a mapping of simplified values specific to this callsite. The - // idea is to propagate any special information we have about arguments to - // this call through the inlinable section of the function, and account for - // likely simplifications post-inlining. The most important aspect we track - // is CFG altering simplifications -- when we prove a basic block dead, that - // can cause dramatic shifts in the cost of inlining a function. + /// While we walk the potentially-inlined instructions, we build up and + /// maintain a mapping of simplified values specific to this callsite. The + /// idea is to propagate any special information we have about arguments to + /// this call through the inlinable section of the function, and account for + /// likely simplifications post-inlining. The most important aspect we track + /// is CFG altering simplifications -- when we prove a basic block dead, that + /// can cause dramatic shifts in the cost of inlining a function. DenseMap SimplifiedValues; - // Keep track of the values which map back (through function arguments) to - // allocas on the caller stack which could be simplified through SROA. + /// Keep track of the values which map back (through function arguments) to + /// allocas on the caller stack which could be simplified through SROA. DenseMap SROAArgValues; - // The mapping of caller Alloca values to their accumulated cost savings. If - // we have to disable SROA for one of the allocas, this tells us how much - // cost must be added. + /// The mapping of caller Alloca values to their accumulated cost savings. If + /// we have to disable SROA for one of the allocas, this tells us how much + /// cost must be added. DenseMap SROAArgCosts; - // Keep track of values which map to a pointer base and constant offset. + /// Keep track of values which map to a pointer base and constant offset. DenseMap> ConstantOffsetPtrs; // Custom simplification helper routines. Index: lib/Analysis/ProfileSummaryInfo.cpp =================================================================== --- lib/Analysis/ProfileSummaryInfo.cpp +++ lib/Analysis/ProfileSummaryInfo.cpp @@ -63,9 +63,9 @@ Summary.reset(ProfileSummary::getFromMD(SummaryMD)); } -// Returns true if the function is a hot function. If it returns false, it -// either means it is not hot or it is unknown whether F is hot or not (for -// example, no profile data is available). +/// Returns true if the function is a hot function. If it returns false, it +/// either means it is not hot or it is unknown whether F is hot or not (for +/// example, no profile data is available). bool ProfileSummaryInfo::isHotFunction(const Function *F) { computeSummary(); if (!F || !Summary) @@ -79,9 +79,9 @@ (uint64_t)(0.3 * (double)Summary->getMaxFunctionCount())); } -// Returns true if the function is a cold function. If it returns false, it -// either means it is not cold or it is unknown whether F is cold or not (for -// example, no profile data is available). +/// Returns true if the function is a cold function. If it returns false, it +/// either means it is not cold or it is unknown whether F is cold or not (for +/// example, no profile data is available). bool ProfileSummaryInfo::isColdFunction(const Function *F) { computeSummary(); if (!F) @@ -100,7 +100,7 @@ (uint64_t)(0.01 * (double)Summary->getMaxFunctionCount())); } -// Compute the hot and cold thresholds. +/// Compute the hot and cold thresholds. void ProfileSummaryInfo::computeThresholds() { if (!Summary) computeSummary(); Index: lib/ProfileData/ProfileSummaryBuilder.cpp =================================================================== --- lib/ProfileData/ProfileSummaryBuilder.cpp +++ lib/ProfileData/ProfileSummaryBuilder.cpp @@ -59,14 +59,14 @@ void ProfileSummaryBuilder::computeDetailedSummary() { if (DetailedSummaryCutoffs.empty()) return; - auto Iter = CountFrequencies.begin(); - auto End = CountFrequencies.end(); std::sort(DetailedSummaryCutoffs.begin(), DetailedSummaryCutoffs.end()); + auto Iter = CountFrequencies.begin(); + const auto End = CountFrequencies.end(); uint32_t CountsSeen = 0; uint64_t CurrSum = 0, Count = 0; - for (uint32_t Cutoff : DetailedSummaryCutoffs) { + for (const uint32_t Cutoff : DetailedSummaryCutoffs) { assert(Cutoff <= 999999); APInt Temp(128, TotalCount); APInt N(128, Cutoff);