-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[NFC] Rename the Nr abbreviation to Num
#107151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
It's more clear. (This isn't exhaustive).
|
@llvm/pr-subscribers-mlgo @llvm/pr-subscribers-pgo Author: Mircea Trofin (mtrofin) ChangesIt's more clear. (This isn't exhaustive). Patch is 28.60 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/107151.diff 11 Files Affected:
diff --git a/compiler-rt/lib/ctx_profile/CtxInstrContextNode.h b/compiler-rt/lib/ctx_profile/CtxInstrContextNode.h
index a916f197aa1483..5991458c5732db 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<uint64_t *>(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<ContextNode *>(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<ContextNode **>(&(counters()[NrCounters]));
+ return reinterpret_cast<ContextNode **>(&(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 a0a535015bf2ea..df30986cdfc697 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<uint64_t>(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<void *>(Ret), Guid, NrCallsites,
- NrCounters, Ret->guid(), Ret->callsites_size(),
+ reinterpret_cast<void *>(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 f55068e98dd434..74d346d6e0a073 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 21f155de85aecb..9f7f19a369d9ca 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 a916f197aa1483..5991458c5732db 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<uint64_t *>(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<ContextNode *>(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<ContextNode **>(&(counters()[NrCounters]));
+ return reinterpret_cast<ContextNode **>(&(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 af6574052c8c89..0ffbc90d7ee22d 100644
--- a/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
+++ b/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
@@ -47,7 +47,7 @@ static cl::opt<unsigned> 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<BranchInst>(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<CallBase>(&I)) {
const auto *Callee = CS->getCalledFunction();
diff --git a/llvm/lib/Analysis/MLInlineAdvisor.cpp b/llvm/lib/Analysis/MLInlineAdvisor.cpp
index 8bb5efcf1b2ecb..2db58d1c2578bf 100644
--- a/llvm/lib/Analysis/MLInlineAdvisor.cpp
+++ b/llvm/lib/Analysis/MLInlineAdvisor.cpp
@@ -400,9 +400,9 @@ std::unique_ptr<InlineAdvice> 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<Constant>(*I));
+ NumCtantParams += (isa<Constant>(*I));
}
auto &CallerBefore = getCachedFPI(Caller);
@@ -414,7 +414,7 @@ std::unique_ptr<InlineAdvice> MLInlineAdvisor::getAdviceImpl(CallBase &CB) {
getInitialFunctionLevel(Caller);
*ModelRunner->getTensor<int64_t>(FeatureIndex::node_count) = NodeCount;
*ModelRunner->getTensor<int64_t>(FeatureIndex::nr_ctant_params) =
- NrCtantParams;
+ NumCtantParams;
*ModelRunner->getTensor<int64_t>(FeatureIndex::edge_count) = EdgeCount;
*ModelRunner->getTensor<int64_t>(FeatureIndex::caller_users) =
CallerBefore.Uses;
diff --git a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp
index 0a124ac3fd1b68..d099544c2a4918 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<const LiveInterval *> &Intervals,
llvm::SmallVectorImpl<float> &Largest, size_t Pos,
- int64_t IsHint, int64_t LocalIntfsCount, float NrUrgent,
+ int64_t IsHint, int64_t LocalIntfsCount, float NumUrgent,
SmallVectorImpl<LRStartEndInfo> &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<const LiveInterval *, 1>(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<const LiveInterval *> &Intervals,
llvm::SmallVectorImpl<float> &Largest, size_t Pos, int64_t IsHint,
- int64_t LocalIntfsCount, float NrUrgent,
+ int64_t LocalIntfsCount, float NumUrgent,
SmallVectorImpl<LRStartEndInfo> &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 43bebc99316e06..b620306628729b 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<ui...
[truncated]
|
mingmingl-llvm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
It's more clear. (This isn't exhaustive).