diff --git a/compiler-rt/lib/ctx_profile/CtxInstrContextNode.h b/compiler-rt/lib/ctx_profile/CtxInstrContextNode.h index a916f197aa148..5991458c5732d 100644 --- a/compiler-rt/lib/ctx_profile/CtxInstrContextNode.h +++ b/compiler-rt/lib/ctx_profile/CtxInstrContextNode.h @@ -68,18 +68,19 @@ using GUID = uint64_t; class ContextNode final { const GUID Guid; ContextNode *const Next; - const uint32_t NrCounters; - const uint32_t NrCallsites; + const uint32_t NumCounters; + const uint32_t NumCallsites; public: - ContextNode(GUID Guid, uint32_t NrCounters, uint32_t NrCallsites, + ContextNode(GUID Guid, uint32_t NumCounters, uint32_t NumCallsites, ContextNode *Next = nullptr) - : Guid(Guid), Next(Next), NrCounters(NrCounters), - NrCallsites(NrCallsites) {} + : Guid(Guid), Next(Next), NumCounters(NumCounters), + NumCallsites(NumCallsites) {} - static inline size_t getAllocSize(uint32_t NrCounters, uint32_t NrCallsites) { - return sizeof(ContextNode) + sizeof(uint64_t) * NrCounters + - sizeof(ContextNode *) * NrCallsites; + static inline size_t getAllocSize(uint32_t NumCounters, + uint32_t NumCallsites) { + return sizeof(ContextNode) + sizeof(uint64_t) * NumCounters + + sizeof(ContextNode *) * NumCallsites; } // The counters vector starts right after the static header. @@ -88,8 +89,8 @@ class ContextNode final { return reinterpret_cast(addr_after); } - uint32_t counters_size() const { return NrCounters; } - uint32_t callsites_size() const { return NrCallsites; } + uint32_t counters_size() const { return NumCounters; } + uint32_t callsites_size() const { return NumCallsites; } const uint64_t *counters() const { return const_cast(this)->counters(); @@ -97,7 +98,7 @@ class ContextNode final { // The subcontexts vector starts right after the end of the counters vector. ContextNode **subContexts() { - return reinterpret_cast(&(counters()[NrCounters])); + return reinterpret_cast(&(counters()[NumCounters])); } ContextNode *const *subContexts() const { @@ -107,7 +108,7 @@ class ContextNode final { GUID guid() const { return Guid; } ContextNode *next() const { return Next; } - size_t size() const { return getAllocSize(NrCounters, NrCallsites); } + size_t size() const { return getAllocSize(NumCounters, NumCallsites); } uint64_t entrycount() const { return counters()[0]; } }; diff --git a/compiler-rt/lib/ctx_profile/CtxInstrProfiling.cpp b/compiler-rt/lib/ctx_profile/CtxInstrProfiling.cpp index a0a535015bf2e..df30986cdfc69 100644 --- a/compiler-rt/lib/ctx_profile/CtxInstrProfiling.cpp +++ b/compiler-rt/lib/ctx_profile/CtxInstrProfiling.cpp @@ -92,10 +92,11 @@ bool validate(const ContextRoot *Root) { } inline ContextNode *allocContextNode(char *Place, GUID Guid, - uint32_t NrCounters, uint32_t NrCallsites, + uint32_t NumCounters, + uint32_t NumCallsites, ContextNode *Next = nullptr) { assert(reinterpret_cast(Place) % ExpectedAlignment == 0); - return new (Place) ContextNode(Guid, NrCounters, NrCallsites, Next); + return new (Place) ContextNode(Guid, NumCounters, NumCallsites, Next); } void resetContextNode(ContextNode &Node) { @@ -161,8 +162,8 @@ void Arena::freeArenaList(Arena *&A) { // If this is the first time we hit a callsite with this (Guid) particular // callee, we need to allocate. ContextNode *getCallsiteSlow(GUID Guid, ContextNode **InsertionPoint, - uint32_t NrCounters, uint32_t NrCallsites) { - auto AllocSize = ContextNode::getAllocSize(NrCounters, NrCallsites); + uint32_t NumCounters, uint32_t NumCallsites) { + auto AllocSize = ContextNode::getAllocSize(NumCounters, NumCallsites); auto *Mem = __llvm_ctx_profile_current_context_root->CurrentMem; char *AllocPlace = Mem->tryBumpAllocate(AllocSize); if (!AllocPlace) { @@ -175,15 +176,15 @@ ContextNode *getCallsiteSlow(GUID Guid, ContextNode **InsertionPoint, Mem->allocateNewArena(getArenaAllocSize(AllocSize), Mem); AllocPlace = Mem->tryBumpAllocate(AllocSize); } - auto *Ret = allocContextNode(AllocPlace, Guid, NrCounters, NrCallsites, + auto *Ret = allocContextNode(AllocPlace, Guid, NumCounters, NumCallsites, *InsertionPoint); *InsertionPoint = Ret; return Ret; } ContextNode *__llvm_ctx_profile_get_context(void *Callee, GUID Guid, - uint32_t NrCounters, - uint32_t NrCallsites) { + uint32_t NumCounters, + uint32_t NumCallsites) { // fast "out" if we're not even doing contextual collection. if (!__llvm_ctx_profile_current_context_root) return TheScratchContext; @@ -222,14 +223,14 @@ ContextNode *__llvm_ctx_profile_get_context(void *Callee, GUID Guid, Callsite = Callsite->next(); } auto *Ret = Callsite ? Callsite - : getCallsiteSlow(Guid, CallsiteContext, NrCounters, - NrCallsites); - if (Ret->callsites_size() != NrCallsites || - Ret->counters_size() != NrCounters) + : getCallsiteSlow(Guid, CallsiteContext, NumCounters, + NumCallsites); + if (Ret->callsites_size() != NumCallsites || + Ret->counters_size() != NumCounters) __sanitizer::Printf("[ctxprof] Returned ctx differs from what's asked: " "Context: %p, Asked: %lu %u %u, Got: %lu %u %u \n", - reinterpret_cast(Ret), Guid, NrCallsites, - NrCounters, Ret->guid(), Ret->callsites_size(), + reinterpret_cast(Ret), Guid, NumCallsites, + NumCounters, Ret->guid(), Ret->callsites_size(), Ret->counters_size()); onContextEnter(*Ret); return Ret; @@ -237,19 +238,19 @@ ContextNode *__llvm_ctx_profile_get_context(void *Callee, GUID Guid, // This should be called once for a Root. Allocate the first arena, set up the // first context. -void setupContext(ContextRoot *Root, GUID Guid, uint32_t NrCounters, - uint32_t NrCallsites) { +void setupContext(ContextRoot *Root, GUID Guid, uint32_t NumCounters, + uint32_t NumCallsites) { __sanitizer::GenericScopedLock<__sanitizer::SpinMutex> Lock( &AllContextsMutex); // Re-check - we got here without having had taken a lock. if (Root->FirstMemBlock) return; - const auto Needed = ContextNode::getAllocSize(NrCounters, NrCallsites); + const auto Needed = ContextNode::getAllocSize(NumCounters, NumCallsites); auto *M = Arena::allocateNewArena(getArenaAllocSize(Needed)); Root->FirstMemBlock = M; Root->CurrentMem = M; Root->FirstNode = allocContextNode(M->tryBumpAllocate(Needed), Guid, - NrCounters, NrCallsites); + NumCounters, NumCallsites); AllContextRoots.PushBack(Root); } @@ -278,7 +279,7 @@ void __llvm_ctx_profile_release_context(ContextRoot *Root) } void __llvm_ctx_profile_start_collection() { - size_t NrMemUnits = 0; + size_t NumMemUnits = 0; __sanitizer::GenericScopedLock<__sanitizer::SpinMutex> Lock( &AllContextsMutex); for (uint32_t I = 0; I < AllContextRoots.Size(); ++I) { @@ -286,11 +287,11 @@ void __llvm_ctx_profile_start_collection() { __sanitizer::GenericScopedLock<__sanitizer::StaticSpinMutex> Lock( &Root->Taken); for (auto *Mem = Root->FirstMemBlock; Mem; Mem = Mem->next()) - ++NrMemUnits; + ++NumMemUnits; resetContextNode(*Root->FirstNode); } - __sanitizer::Printf("[ctxprof] Initial NrMemUnits: %zu \n", NrMemUnits); + __sanitizer::Printf("[ctxprof] Initial NumMemUnits: %zu \n", NumMemUnits); } bool __llvm_ctx_profile_fetch(void *Data, diff --git a/compiler-rt/lib/ctx_profile/CtxInstrProfiling.h b/compiler-rt/lib/ctx_profile/CtxInstrProfiling.h index f55068e98dd43..74d346d6e0a07 100644 --- a/compiler-rt/lib/ctx_profile/CtxInstrProfiling.h +++ b/compiler-rt/lib/ctx_profile/CtxInstrProfiling.h @@ -153,8 +153,8 @@ void __llvm_ctx_profile_release_context(__ctx_profile::ContextRoot *Root); /// called for any other function than entry points, in the entry BB of such /// function. Same consideration about LSB of returned value as .._start_context ContextNode *__llvm_ctx_profile_get_context(void *Callee, GUID Guid, - uint32_t NrCounters, - uint32_t NrCallsites); + uint32_t NumCounters, + uint32_t NumCallsites); /// Prepares for collection. Currently this resets counter values but preserves /// internal context tree structure. diff --git a/llvm/include/llvm/Analysis/MLModelRunner.h b/llvm/include/llvm/Analysis/MLModelRunner.h index 21f155de85aec..9f7f19a369d9c 100644 --- a/llvm/include/llvm/Analysis/MLModelRunner.h +++ b/llvm/include/llvm/Analysis/MLModelRunner.h @@ -54,8 +54,8 @@ class MLModelRunner { virtual void switchContext(StringRef Name) {} protected: - MLModelRunner(LLVMContext &Ctx, Kind Type, size_t NrInputs) - : Ctx(Ctx), Type(Type), InputBuffers(NrInputs) { + MLModelRunner(LLVMContext &Ctx, Kind Type, size_t NumInputs) + : Ctx(Ctx), Type(Type), InputBuffers(NumInputs) { assert(Type != Kind::Unknown); } virtual void *evaluateUntyped() = 0; diff --git a/llvm/include/llvm/ProfileData/CtxInstrContextNode.h b/llvm/include/llvm/ProfileData/CtxInstrContextNode.h index a916f197aa148..5991458c5732d 100644 --- a/llvm/include/llvm/ProfileData/CtxInstrContextNode.h +++ b/llvm/include/llvm/ProfileData/CtxInstrContextNode.h @@ -68,18 +68,19 @@ using GUID = uint64_t; class ContextNode final { const GUID Guid; ContextNode *const Next; - const uint32_t NrCounters; - const uint32_t NrCallsites; + const uint32_t NumCounters; + const uint32_t NumCallsites; public: - ContextNode(GUID Guid, uint32_t NrCounters, uint32_t NrCallsites, + ContextNode(GUID Guid, uint32_t NumCounters, uint32_t NumCallsites, ContextNode *Next = nullptr) - : Guid(Guid), Next(Next), NrCounters(NrCounters), - NrCallsites(NrCallsites) {} + : Guid(Guid), Next(Next), NumCounters(NumCounters), + NumCallsites(NumCallsites) {} - static inline size_t getAllocSize(uint32_t NrCounters, uint32_t NrCallsites) { - return sizeof(ContextNode) + sizeof(uint64_t) * NrCounters + - sizeof(ContextNode *) * NrCallsites; + static inline size_t getAllocSize(uint32_t NumCounters, + uint32_t NumCallsites) { + return sizeof(ContextNode) + sizeof(uint64_t) * NumCounters + + sizeof(ContextNode *) * NumCallsites; } // The counters vector starts right after the static header. @@ -88,8 +89,8 @@ class ContextNode final { return reinterpret_cast(addr_after); } - uint32_t counters_size() const { return NrCounters; } - uint32_t callsites_size() const { return NrCallsites; } + uint32_t counters_size() const { return NumCounters; } + uint32_t callsites_size() const { return NumCallsites; } const uint64_t *counters() const { return const_cast(this)->counters(); @@ -97,7 +98,7 @@ class ContextNode final { // The subcontexts vector starts right after the end of the counters vector. ContextNode **subContexts() { - return reinterpret_cast(&(counters()[NrCounters])); + return reinterpret_cast(&(counters()[NumCounters])); } ContextNode *const *subContexts() const { @@ -107,7 +108,7 @@ class ContextNode final { GUID guid() const { return Guid; } ContextNode *next() const { return Next; } - size_t size() const { return getAllocSize(NrCounters, NrCallsites); } + size_t size() const { return getAllocSize(NumCounters, NumCallsites); } uint64_t entrycount() const { return counters()[0]; } }; diff --git a/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp b/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp index af6574052c8c8..0ffbc90d7ee22 100644 --- a/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp +++ b/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp @@ -47,7 +47,7 @@ static cl::opt CallWithManyArgumentsThreshold( "it is considered having many arguments.")); namespace { -int64_t getNrBlocksFromCond(const BasicBlock &BB) { +int64_t getNumBlocksFromCond(const BasicBlock &BB) { int64_t Ret = 0; if (const auto *BI = dyn_cast(BB.getTerminator())) { if (BI->isConditional()) @@ -72,7 +72,7 @@ void FunctionPropertiesInfo::updateForBB(const BasicBlock &BB, assert(Direction == 1 || Direction == -1); BasicBlockCount += Direction; BlocksReachedFromConditionalInstruction += - (Direction * getNrBlocksFromCond(BB)); + (Direction * getNumBlocksFromCond(BB)); for (const auto &I : BB) { if (auto *CS = dyn_cast(&I)) { const auto *Callee = CS->getCalledFunction(); diff --git a/llvm/lib/Analysis/MLInlineAdvisor.cpp b/llvm/lib/Analysis/MLInlineAdvisor.cpp index 8bb5efcf1b2ec..2db58d1c2578b 100644 --- a/llvm/lib/Analysis/MLInlineAdvisor.cpp +++ b/llvm/lib/Analysis/MLInlineAdvisor.cpp @@ -400,9 +400,9 @@ std::unique_ptr MLInlineAdvisor::getAdviceImpl(CallBase &CB) { if (Mandatory) return getMandatoryAdvice(CB, true); - auto NrCtantParams = 0; + auto NumCtantParams = 0; for (auto I = CB.arg_begin(), E = CB.arg_end(); I != E; ++I) { - NrCtantParams += (isa(*I)); + NumCtantParams += (isa(*I)); } auto &CallerBefore = getCachedFPI(Caller); @@ -414,7 +414,7 @@ std::unique_ptr MLInlineAdvisor::getAdviceImpl(CallBase &CB) { getInitialFunctionLevel(Caller); *ModelRunner->getTensor(FeatureIndex::node_count) = NodeCount; *ModelRunner->getTensor(FeatureIndex::nr_ctant_params) = - NrCtantParams; + NumCtantParams; *ModelRunner->getTensor(FeatureIndex::edge_count) = EdgeCount; *ModelRunner->getTensor(FeatureIndex::caller_users) = CallerBefore.Uses; diff --git a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp index 0a124ac3fd1b6..d099544c2a491 100644 --- a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp +++ b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp @@ -273,7 +273,7 @@ struct LIFeatureComponents { double RW = 0; double IndVarUpdates = 0; double HintWeights = 0.0; - int64_t NrDefsAndUses = 0; + int64_t NumDefsAndUses = 0; float HottestBlockFreq = 0.0; bool IsRemat = false; }; @@ -327,7 +327,7 @@ class MLEvictAdvisor : public RegAllocEvictionAdvisor { void extractFeatures(const SmallVectorImpl &Intervals, llvm::SmallVectorImpl &Largest, size_t Pos, - int64_t IsHint, int64_t LocalIntfsCount, float NrUrgent, + int64_t IsHint, int64_t LocalIntfsCount, float NumUrgent, SmallVectorImpl &LRPosInfo) const; // Point-in-time: we didn't learn this, so we always delegate to the @@ -609,7 +609,7 @@ bool MLEvictAdvisor::loadInterferenceFeatures( const bool IsLocal = LIS->intervalIsInOneMBB(VirtReg); int64_t LocalIntfs = 0; - float NrUrgent = 0.0f; + float NumUrgent = 0.0f; // The cascade tracking is the same as in the default advisor unsigned Cascade = RA.getExtraInfo().getCascadeOrCurrentNext(VirtReg.reg()); @@ -649,7 +649,7 @@ bool MLEvictAdvisor::loadInterferenceFeatures( if (Cascade <= IntfCascade) { if (!Urgent) return false; - ++NrUrgent; + ++NumUrgent; } LocalIntfs += (IsLocal && LIS->intervalIsInOneMBB(*Intf) && @@ -659,7 +659,7 @@ bool MLEvictAdvisor::loadInterferenceFeatures( // OK, so if we made it this far, this LR is an eviction candidate, load its // features. extractFeatures(InterferingIntervals, Largest, Pos, IsHint, LocalIntfs, - NrUrgent, LRPosInfo); + NumUrgent, LRPosInfo); return true; } @@ -731,7 +731,7 @@ MCRegister MLEvictAdvisor::tryFindEvictionCandidate( extractFeatures(SmallVector(1, &VirtReg), Largest, CandidateVirtRegPos, /*IsHint*/ 0, /*LocalIntfsCount*/ 0, - /*NrUrgent*/ 0.0, LRPosInfo); + /*NumUrgent*/ 0.0, LRPosInfo); assert(InitialQSize > 0.0 && "We couldn't have gotten here if we had " "nothing to allocate initially."); #ifdef LLVM_HAVE_TFLITE @@ -809,7 +809,7 @@ MLEvictAdvisor::getLIFeatureComponents(const LiveInterval &LI) const { I != E;) { MachineInstr *MI = &*(I++); - ++Ret.NrDefsAndUses; + ++Ret.NumDefsAndUses; if (!Visited.insert(MI).second) continue; @@ -846,10 +846,10 @@ MLEvictAdvisor::getLIFeatureComponents(const LiveInterval &LI) const { void MLEvictAdvisor::extractFeatures( const SmallVectorImpl &Intervals, llvm::SmallVectorImpl &Largest, size_t Pos, int64_t IsHint, - int64_t LocalIntfsCount, float NrUrgent, + int64_t LocalIntfsCount, float NumUrgent, SmallVectorImpl &LRPosInfo) const { - int64_t NrDefsAndUses = 0; - int64_t NrBrokenHints = 0; + int64_t NumDefsAndUses = 0; + int64_t NumBrokenHints = 0; double R = 0.0; double W = 0.0; double RW = 0.0; @@ -858,7 +858,7 @@ void MLEvictAdvisor::extractFeatures( float StartBBFreq = 0.0; float EndBBFreq = 0.0; float HottestBlockFreq = 0.0; - int32_t NrRematerializable = 0; + int32_t NumRematerializable = 0; float TotalWeight = 0.0; SlotIndex EndSI = LIS->getSlotIndexes()->getZeroIndex(); @@ -882,9 +882,9 @@ void MLEvictAdvisor::extractFeatures( if (LI.endIndex() > EndSI) EndSI = LI.endIndex(); const LIFeatureComponents &LIFC = getLIFeatureComponents(LI); - NrBrokenHints += VRM->hasPreferredPhys(LI.reg()); + NumBrokenHints += VRM->hasPreferredPhys(LI.reg()); - NrDefsAndUses += LIFC.NrDefsAndUses; + NumDefsAndUses += LIFC.NumDefsAndUses; HottestBlockFreq = std::max(HottestBlockFreq, LIFC.HottestBlockFreq); R += LIFC.R; W += LIFC.W; @@ -893,7 +893,7 @@ void MLEvictAdvisor::extractFeatures( IndVarUpdates += LIFC.IndVarUpdates; HintWeights += LIFC.HintWeights; - NrRematerializable += LIFC.IsRemat; + NumRematerializable += LIFC.IsRemat; if (EnableDevelopmentFeatures) { for (auto CurrentSegment : LI) { @@ -922,12 +922,12 @@ void MLEvictAdvisor::extractFeatures( } while (false) SET(mask, int64_t, 1); SET(is_free, int64_t, Intervals.empty()); - SET(nr_urgent, float, NrUrgent); - SET(nr_broken_hints, float, NrBrokenHints); + SET(nr_urgent, float, NumUrgent); + SET(nr_broken_hints, float, NumBrokenHints); SET(is_hint, int64_t, IsHint); SET(is_local, int64_t, LocalIntfsCount); - SET(nr_rematerializable, float, NrRematerializable); - SET(nr_defs_and_uses, float, NrDefsAndUses); + SET(nr_rematerializable, float, NumRematerializable); + SET(nr_defs_and_uses, float, NumDefsAndUses); SET(weighed_reads_by_max, float, R); SET(weighed_writes_by_max, float, W); SET(weighed_read_writes_by_max, float, RW); diff --git a/llvm/lib/Transforms/Instrumentation/PGOCtxProfLowering.cpp b/llvm/lib/Transforms/Instrumentation/PGOCtxProfLowering.cpp index 43bebc99316e0..b620306628729 100644 --- a/llvm/lib/Transforms/Instrumentation/PGOCtxProfLowering.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOCtxProfLowering.cpp @@ -71,33 +71,33 @@ class CtxInstrumentationLowerer final { // of its parameters, and llvm.instrprof.callsite captures the total number of // callsites. Those values are the same for instances of those intrinsics in // this function. Find the first instance of each and return them. -std::pair getNrCountersAndCallsites(const Function &F) { - uint32_t NrCounters = 0; - uint32_t NrCallsites = 0; +std::pair getNumCountersAndCallsites(const Function &F) { + uint32_t NumCounters = 0; + uint32_t NumCallsites = 0; for (const auto &BB : F) { for (const auto &I : BB) { if (const auto *Incr = dyn_cast(&I)) { uint32_t V = static_cast(Incr->getNumCounters()->getZExtValue()); - assert((!NrCounters || V == NrCounters) && + assert((!NumCounters || V == NumCounters) && "expected all llvm.instrprof.increment[.step] intrinsics to " "have the same total nr of counters parameter"); - NrCounters = V; + NumCounters = V; } else if (const auto *CSIntr = dyn_cast(&I)) { uint32_t V = static_cast(CSIntr->getNumCounters()->getZExtValue()); - assert((!NrCallsites || V == NrCallsites) && + assert((!NumCallsites || V == NumCallsites) && "expected all llvm.instrprof.callsite intrinsics to have the " "same total nr of callsites parameter"); - NrCallsites = V; + NumCallsites = V; } #if NDEBUG - if (NrCounters && NrCallsites) - return std::make_pair(NrCounters, NrCallsites); + if (NumCounters && NumCallsites) + return std::make_pair(NumCounters, NumCallsites); #endif } } - return {NrCounters, NrCallsites}; + return {NumCounters, NumCallsites}; } } // namespace @@ -124,8 +124,8 @@ CtxInstrumentationLowerer::CtxInstrumentationLowerer(Module &M, ContextNodeTy = StructType::get(M.getContext(), { I64Ty, /*Guid*/ PointerTy, /*Next*/ - I32Ty, /*NrCounters*/ - I32Ty, /*NrCallsites*/ + I32Ty, /*NumCounters*/ + I32Ty, /*NumCallsites*/ }); // Define a global for each entrypoint. We'll reuse the entrypoint's name as @@ -157,7 +157,7 @@ CtxInstrumentationLowerer::CtxInstrumentationLowerer(Module &M, FunctionType::get(ContextNodeTy->getPointerTo(), {ContextRootTy->getPointerTo(), /*ContextRoot*/ I64Ty, /*Guid*/ I32Ty, - /*NrCounters*/ I32Ty /*NrCallsites*/}, + /*NumCounters*/ I32Ty /*NumCallsites*/}, false)) .getCallee()); GetCtx = cast( @@ -165,8 +165,8 @@ CtxInstrumentationLowerer::CtxInstrumentationLowerer(Module &M, FunctionType::get(ContextNodeTy->getPointerTo(), {PointerTy, /*Callee*/ I64Ty, /*Guid*/ - I32Ty, /*NrCounters*/ - I32Ty}, /*NrCallsites*/ + I32Ty, /*NumCounters*/ + I32Ty}, /*NumCallsites*/ false)) .getCallee()); ReleaseCtx = cast( @@ -208,7 +208,7 @@ bool CtxInstrumentationLowerer::lowerFunction(Function &F) { auto &ORE = FAM.getResult(F); Value *Guid = nullptr; - auto [NrCounters, NrCallsites] = getNrCountersAndCallsites(F); + auto [NumCounters, NumCallsites] = getNumCountersAndCallsites(F); Value *Context = nullptr; Value *RealContext = nullptr; @@ -229,12 +229,12 @@ bool CtxInstrumentationLowerer::lowerFunction(Function &F) { Guid = Builder.getInt64( AssignGUIDPass::getGUID(cast(*Mark->getNameValue()))); // The type of the context of this function is now knowable since we have - // NrCallsites and NrCounters. We delcare it here because it's more + // NumCallsites and NumCounters. We delcare it here because it's more // convenient - we have the Builder. ThisContextType = StructType::get( F.getContext(), - {ContextNodeTy, ArrayType::get(Builder.getInt64Ty(), NrCounters), - ArrayType::get(Builder.getPtrTy(), NrCallsites)}); + {ContextNodeTy, ArrayType::get(Builder.getInt64Ty(), NumCounters), + ArrayType::get(Builder.getPtrTy(), NumCallsites)}); // Figure out which way we obtain the context object for this function - // if it's an entrypoint, then we call StartCtx, otherwise GetCtx. In the // former case, we also set TheRootContext since we need to release it @@ -243,22 +243,22 @@ bool CtxInstrumentationLowerer::lowerFunction(Function &F) { auto Iter = ContextRootMap.find(&F); if (Iter != ContextRootMap.end()) { TheRootContext = Iter->second; - Context = Builder.CreateCall(StartCtx, {TheRootContext, Guid, - Builder.getInt32(NrCounters), - Builder.getInt32(NrCallsites)}); + Context = Builder.CreateCall( + StartCtx, {TheRootContext, Guid, Builder.getInt32(NumCounters), + Builder.getInt32(NumCallsites)}); ORE.emit( [&] { return OptimizationRemark(DEBUG_TYPE, "Entrypoint", &F); }); } else { Context = - Builder.CreateCall(GetCtx, {&F, Guid, Builder.getInt32(NrCounters), - Builder.getInt32(NrCallsites)}); + Builder.CreateCall(GetCtx, {&F, Guid, Builder.getInt32(NumCounters), + Builder.getInt32(NumCallsites)}); ORE.emit([&] { return OptimizationRemark(DEBUG_TYPE, "RegularFunction", &F); }); } // The context could be scratch. auto *CtxAsInt = Builder.CreatePtrToInt(Context, Builder.getInt64Ty()); - if (NrCallsites > 0) { + if (NumCallsites > 0) { // Figure out which index of the TLS 2-element buffers to use. // Scratch context => we use index == 1. Real contexts => index == 0. auto *Index = Builder.CreateAnd(CtxAsInt, Builder.getInt64(1)); diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp index 8dd0cfdb2ae0a..9dd4a561edfdd 100644 --- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -953,15 +953,15 @@ void FunctionInstrumenter::instrument() { } }; // First, count callsites. - uint32_t TotalNrCallsites = 0; - Visit([&TotalNrCallsites](auto *) { ++TotalNrCallsites; }); + uint32_t TotalNumCallsites = 0; + Visit([&TotalNumCallsites](auto *) { ++TotalNumCallsites; }); // Now instrument. uint32_t CallsiteIndex = 0; Visit([&](auto *CB) { IRBuilder<> Builder(CB); Builder.CreateCall(CSIntrinsic, - {Name, CFGHash, Builder.getInt32(TotalNrCallsites), + {Name, CFGHash, Builder.getInt32(TotalNumCallsites), Builder.getInt32(CallsiteIndex++), CB->getCalledOperand()}); }); diff --git a/llvm/unittests/ProfileData/PGOCtxProfReaderWriterTest.cpp b/llvm/unittests/ProfileData/PGOCtxProfReaderWriterTest.cpp index 7be01445558ec..f48f4f1ac9cc1 100644 --- a/llvm/unittests/ProfileData/PGOCtxProfReaderWriterTest.cpp +++ b/llvm/unittests/ProfileData/PGOCtxProfReaderWriterTest.cpp @@ -24,12 +24,12 @@ class PGOCtxProfRWTest : public ::testing::Test { std::map Roots; public: - ContextNode *createNode(GUID Guid, uint32_t NrCounters, uint32_t NrCallsites, - ContextNode *Next = nullptr) { - auto AllocSize = ContextNode::getAllocSize(NrCounters, NrCallsites); + ContextNode *createNode(GUID Guid, uint32_t NumCounters, + uint32_t NumCallsites, ContextNode *Next = nullptr) { + auto AllocSize = ContextNode::getAllocSize(NumCounters, NumCallsites); auto *Mem = Nodes.emplace_back(std::make_unique(AllocSize)).get(); std::memset(Mem, 0, AllocSize); - auto *Ret = new (Mem) ContextNode(Guid, NrCounters, NrCallsites, Next); + auto *Ret = new (Mem) ContextNode(Guid, NumCounters, NumCallsites, Next); return Ret; }