Skip to content

Commit e291f31

Browse files
authored
[NFC] Coding style fixes in InstrProf.cpp (#98211)
1 parent 9e0347d commit e291f31

File tree

1 file changed

+30
-31
lines changed

1 file changed

+30
-31
lines changed

llvm/lib/ProfileData/InstrProf.cpp

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
#include "llvm/ProfileData/InstrProf.h"
1515
#include "llvm/ADT/ArrayRef.h"
16-
#include "llvm/ADT/SetVector.h"
1716
#include "llvm/ADT/SmallVector.h"
1817
#include "llvm/ADT/StringExtras.h"
1918
#include "llvm/ADT/StringRef.h"
@@ -430,10 +429,10 @@ std::string getPGOFuncNameVarName(StringRef FuncName,
430429

431430
// Now fix up illegal chars in local VarName that may upset the assembler.
432431
const char InvalidChars[] = "-:;<>/\"'";
433-
size_t found = VarName.find_first_of(InvalidChars);
434-
while (found != std::string::npos) {
435-
VarName[found] = '_';
436-
found = VarName.find_first_of(InvalidChars, found + 1);
432+
size_t FoundPos = VarName.find_first_of(InvalidChars);
433+
while (FoundPos != std::string::npos) {
434+
VarName[FoundPos] = '_';
435+
FoundPos = VarName.find_first_of(InvalidChars, FoundPos + 1);
437436
}
438437
return VarName;
439438
}
@@ -454,7 +453,7 @@ GlobalVariable *createPGOFuncNameVar(Module &M,
454453

455454
auto *Value =
456455
ConstantDataArray::getString(M.getContext(), PGOFuncName, false);
457-
auto FuncNameVar =
456+
auto *FuncNameVar =
458457
new GlobalVariable(M, Value->getType(), true, Linkage, Value,
459458
getPGOFuncNameVarName(PGOFuncName, Linkage));
460459

@@ -497,7 +496,7 @@ Error InstrProfSymtab::create(Module &M, bool InLTO) {
497496

498497
Error InstrProfSymtab::addVTableWithName(GlobalVariable &VTable,
499498
StringRef VTablePGOName) {
500-
auto mapName = [&](StringRef Name) -> Error {
499+
auto NameToGUIDMap = [&](StringRef Name) -> Error {
501500
if (Error E = addSymbolName(Name))
502501
return E;
503502

@@ -508,12 +507,12 @@ Error InstrProfSymtab::addVTableWithName(GlobalVariable &VTable,
508507
LLVM_DEBUG(dbgs() << "GUID conflict within one module");
509508
return Error::success();
510509
};
511-
if (Error E = mapName(VTablePGOName))
510+
if (Error E = NameToGUIDMap(VTablePGOName))
512511
return E;
513512

514513
StringRef CanonicalName = getCanonicalName(VTablePGOName);
515514
if (CanonicalName != VTablePGOName)
516-
return mapName(CanonicalName);
515+
return NameToGUIDMap(CanonicalName);
517516

518517
return Error::success();
519518
}
@@ -532,10 +531,10 @@ readAndDecodeStrings(StringRef NameStrings,
532531
P += N;
533532
uint64_t CompressedSize = decodeULEB128(P, &N);
534533
P += N;
535-
bool isCompressed = (CompressedSize != 0);
534+
const bool IsCompressed = (CompressedSize != 0);
536535
SmallVector<uint8_t, 128> UncompressedNameStrings;
537536
StringRef NameStrings;
538-
if (isCompressed) {
537+
if (IsCompressed) {
539538
if (!llvm::compression::zlib::isAvailable())
540539
return make_error<InstrProfError>(instrprof_error::zlib_unavailable);
541540

@@ -601,34 +600,34 @@ StringRef InstrProfSymtab::getCanonicalName(StringRef PGOName) {
601600
// pattern ".xxx" which is kept before matching, other suffixes similar as
602601
// ".llvm." will be stripped.
603602
const std::string UniqSuffix = ".__uniq.";
604-
size_t pos = PGOName.find(UniqSuffix);
605-
if (pos != StringRef::npos)
606-
pos += UniqSuffix.length();
603+
size_t Pos = PGOName.find(UniqSuffix);
604+
if (Pos != StringRef::npos)
605+
Pos += UniqSuffix.length();
607606
else
608-
pos = 0;
607+
Pos = 0;
609608

610609
// Search '.' after ".__uniq." if ".__uniq." exists, otherwise search '.' from
611610
// the beginning.
612-
pos = PGOName.find('.', pos);
613-
if (pos != StringRef::npos && pos != 0)
614-
return PGOName.substr(0, pos);
611+
Pos = PGOName.find('.', Pos);
612+
if (Pos != StringRef::npos && Pos != 0)
613+
return PGOName.substr(0, Pos);
615614

616615
return PGOName;
617616
}
618617

619618
Error InstrProfSymtab::addFuncWithName(Function &F, StringRef PGOFuncName) {
620-
auto mapName = [&](StringRef Name) -> Error {
619+
auto NameToGUIDMap = [&](StringRef Name) -> Error {
621620
if (Error E = addFuncName(Name))
622621
return E;
623622
MD5FuncMap.emplace_back(Function::getGUID(Name), &F);
624623
return Error::success();
625624
};
626-
if (Error E = mapName(PGOFuncName))
625+
if (Error E = NameToGUIDMap(PGOFuncName))
627626
return E;
628627

629628
StringRef CanonicalFuncName = getCanonicalName(PGOFuncName);
630629
if (CanonicalFuncName != PGOFuncName)
631-
return mapName(CanonicalFuncName);
630+
return NameToGUIDMap(CanonicalFuncName);
632631

633632
return Error::success();
634633
}
@@ -661,7 +660,7 @@ void InstrProfSymtab::dumpNames(raw_ostream &OS) const {
661660
}
662661

663662
Error collectGlobalObjectNameStrings(ArrayRef<std::string> NameStrs,
664-
bool doCompression, std::string &Result) {
663+
bool DoCompression, std::string &Result) {
665664
assert(!NameStrs.empty() && "No name data to emit");
666665

667666
uint8_t Header[20], *P = Header;
@@ -685,7 +684,7 @@ Error collectGlobalObjectNameStrings(ArrayRef<std::string> NameStrs,
685684
return Error::success();
686685
};
687686

688-
if (!doCompression) {
687+
if (!DoCompression) {
689688
return WriteStringToResult(0, UncompressedNameStrings);
690689
}
691690

@@ -706,22 +705,22 @@ StringRef getPGOFuncNameVarInitializer(GlobalVariable *NameVar) {
706705
}
707706

708707
Error collectPGOFuncNameStrings(ArrayRef<GlobalVariable *> NameVars,
709-
std::string &Result, bool doCompression) {
708+
std::string &Result, bool DoCompression) {
710709
std::vector<std::string> NameStrs;
711710
for (auto *NameVar : NameVars) {
712711
NameStrs.push_back(std::string(getPGOFuncNameVarInitializer(NameVar)));
713712
}
714713
return collectGlobalObjectNameStrings(
715-
NameStrs, compression::zlib::isAvailable() && doCompression, Result);
714+
NameStrs, compression::zlib::isAvailable() && DoCompression, Result);
716715
}
717716

718717
Error collectVTableStrings(ArrayRef<GlobalVariable *> VTables,
719-
std::string &Result, bool doCompression) {
718+
std::string &Result, bool DoCompression) {
720719
std::vector<std::string> VTableNameStrs;
721720
for (auto *VTable : VTables)
722721
VTableNameStrs.push_back(getPGOName(*VTable));
723722
return collectGlobalObjectNameStrings(
724-
VTableNameStrs, compression::zlib::isAvailable() && doCompression,
723+
VTableNameStrs, compression::zlib::isAvailable() && DoCompression,
725724
Result);
726725
}
727726

@@ -1436,7 +1435,7 @@ bool needsComdatForCounter(const GlobalObject &GO, const Module &M) {
14361435

14371436
// Check if INSTR_PROF_RAW_VERSION_VAR is defined.
14381437
bool isIRPGOFlagSet(const Module *M) {
1439-
auto IRInstrVar =
1438+
const GlobalVariable *IRInstrVar =
14401439
M->getNamedGlobal(INSTR_PROF_QUOTE(INSTR_PROF_RAW_VERSION_VAR));
14411440
if (!IRInstrVar || IRInstrVar->hasLocalLinkage())
14421441
return false;
@@ -1500,7 +1499,7 @@ void createProfileFileNameVar(Module &M, StringRef InstrProfileOutput) {
15001499
Error OverlapStats::accumulateCounts(const std::string &BaseFilename,
15011500
const std::string &TestFilename,
15021501
bool IsCS) {
1503-
auto getProfileSum = [IsCS](const std::string &Filename,
1502+
auto GetProfileSum = [IsCS](const std::string &Filename,
15041503
CountSumOrPercent &Sum) -> Error {
15051504
// This function is only used from llvm-profdata that doesn't use any kind
15061505
// of VFS. Just create a default RealFileSystem to read profiles.
@@ -1513,10 +1512,10 @@ Error OverlapStats::accumulateCounts(const std::string &BaseFilename,
15131512
Reader->accumulateCounts(Sum, IsCS);
15141513
return Error::success();
15151514
};
1516-
auto Ret = getProfileSum(BaseFilename, Base);
1515+
auto Ret = GetProfileSum(BaseFilename, Base);
15171516
if (Ret)
15181517
return Ret;
1519-
Ret = getProfileSum(TestFilename, Test);
1518+
Ret = GetProfileSum(TestFilename, Test);
15201519
if (Ret)
15211520
return Ret;
15221521
this->BaseFilename = &BaseFilename;

0 commit comments

Comments
 (0)