13
13
14
14
#include " llvm/ProfileData/InstrProf.h"
15
15
#include " llvm/ADT/ArrayRef.h"
16
- #include " llvm/ADT/SetVector.h"
17
16
#include " llvm/ADT/SmallVector.h"
18
17
#include " llvm/ADT/StringExtras.h"
19
18
#include " llvm/ADT/StringRef.h"
@@ -430,10 +429,10 @@ std::string getPGOFuncNameVarName(StringRef FuncName,
430
429
431
430
// Now fix up illegal chars in local VarName that may upset the assembler.
432
431
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 );
437
436
}
438
437
return VarName;
439
438
}
@@ -454,7 +453,7 @@ GlobalVariable *createPGOFuncNameVar(Module &M,
454
453
455
454
auto *Value =
456
455
ConstantDataArray::getString (M.getContext (), PGOFuncName, false );
457
- auto FuncNameVar =
456
+ auto * FuncNameVar =
458
457
new GlobalVariable (M, Value->getType (), true , Linkage, Value,
459
458
getPGOFuncNameVarName (PGOFuncName, Linkage));
460
459
@@ -497,7 +496,7 @@ Error InstrProfSymtab::create(Module &M, bool InLTO) {
497
496
498
497
Error InstrProfSymtab::addVTableWithName (GlobalVariable &VTable,
499
498
StringRef VTablePGOName) {
500
- auto mapName = [&](StringRef Name) -> Error {
499
+ auto NameToGUIDMap = [&](StringRef Name) -> Error {
501
500
if (Error E = addSymbolName (Name))
502
501
return E;
503
502
@@ -508,12 +507,12 @@ Error InstrProfSymtab::addVTableWithName(GlobalVariable &VTable,
508
507
LLVM_DEBUG (dbgs () << " GUID conflict within one module" );
509
508
return Error::success ();
510
509
};
511
- if (Error E = mapName (VTablePGOName))
510
+ if (Error E = NameToGUIDMap (VTablePGOName))
512
511
return E;
513
512
514
513
StringRef CanonicalName = getCanonicalName (VTablePGOName);
515
514
if (CanonicalName != VTablePGOName)
516
- return mapName (CanonicalName);
515
+ return NameToGUIDMap (CanonicalName);
517
516
518
517
return Error::success ();
519
518
}
@@ -532,10 +531,10 @@ readAndDecodeStrings(StringRef NameStrings,
532
531
P += N;
533
532
uint64_t CompressedSize = decodeULEB128 (P, &N);
534
533
P += N;
535
- bool isCompressed = (CompressedSize != 0 );
534
+ const bool IsCompressed = (CompressedSize != 0 );
536
535
SmallVector<uint8_t , 128 > UncompressedNameStrings;
537
536
StringRef NameStrings;
538
- if (isCompressed ) {
537
+ if (IsCompressed ) {
539
538
if (!llvm::compression::zlib::isAvailable ())
540
539
return make_error<InstrProfError>(instrprof_error::zlib_unavailable);
541
540
@@ -601,34 +600,34 @@ StringRef InstrProfSymtab::getCanonicalName(StringRef PGOName) {
601
600
// pattern ".xxx" which is kept before matching, other suffixes similar as
602
601
// ".llvm." will be stripped.
603
602
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 ();
607
606
else
608
- pos = 0 ;
607
+ Pos = 0 ;
609
608
610
609
// Search '.' after ".__uniq." if ".__uniq." exists, otherwise search '.' from
611
610
// 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 );
615
614
616
615
return PGOName;
617
616
}
618
617
619
618
Error InstrProfSymtab::addFuncWithName (Function &F, StringRef PGOFuncName) {
620
- auto mapName = [&](StringRef Name) -> Error {
619
+ auto NameToGUIDMap = [&](StringRef Name) -> Error {
621
620
if (Error E = addFuncName (Name))
622
621
return E;
623
622
MD5FuncMap.emplace_back (Function::getGUID (Name), &F);
624
623
return Error::success ();
625
624
};
626
- if (Error E = mapName (PGOFuncName))
625
+ if (Error E = NameToGUIDMap (PGOFuncName))
627
626
return E;
628
627
629
628
StringRef CanonicalFuncName = getCanonicalName (PGOFuncName);
630
629
if (CanonicalFuncName != PGOFuncName)
631
- return mapName (CanonicalFuncName);
630
+ return NameToGUIDMap (CanonicalFuncName);
632
631
633
632
return Error::success ();
634
633
}
@@ -661,7 +660,7 @@ void InstrProfSymtab::dumpNames(raw_ostream &OS) const {
661
660
}
662
661
663
662
Error collectGlobalObjectNameStrings (ArrayRef<std::string> NameStrs,
664
- bool doCompression , std::string &Result) {
663
+ bool DoCompression , std::string &Result) {
665
664
assert (!NameStrs.empty () && " No name data to emit" );
666
665
667
666
uint8_t Header[20 ], *P = Header;
@@ -685,7 +684,7 @@ Error collectGlobalObjectNameStrings(ArrayRef<std::string> NameStrs,
685
684
return Error::success ();
686
685
};
687
686
688
- if (!doCompression ) {
687
+ if (!DoCompression ) {
689
688
return WriteStringToResult (0 , UncompressedNameStrings);
690
689
}
691
690
@@ -706,22 +705,22 @@ StringRef getPGOFuncNameVarInitializer(GlobalVariable *NameVar) {
706
705
}
707
706
708
707
Error collectPGOFuncNameStrings (ArrayRef<GlobalVariable *> NameVars,
709
- std::string &Result, bool doCompression ) {
708
+ std::string &Result, bool DoCompression ) {
710
709
std::vector<std::string> NameStrs;
711
710
for (auto *NameVar : NameVars) {
712
711
NameStrs.push_back (std::string (getPGOFuncNameVarInitializer (NameVar)));
713
712
}
714
713
return collectGlobalObjectNameStrings (
715
- NameStrs, compression::zlib::isAvailable () && doCompression , Result);
714
+ NameStrs, compression::zlib::isAvailable () && DoCompression , Result);
716
715
}
717
716
718
717
Error collectVTableStrings (ArrayRef<GlobalVariable *> VTables,
719
- std::string &Result, bool doCompression ) {
718
+ std::string &Result, bool DoCompression ) {
720
719
std::vector<std::string> VTableNameStrs;
721
720
for (auto *VTable : VTables)
722
721
VTableNameStrs.push_back (getPGOName (*VTable));
723
722
return collectGlobalObjectNameStrings (
724
- VTableNameStrs, compression::zlib::isAvailable () && doCompression ,
723
+ VTableNameStrs, compression::zlib::isAvailable () && DoCompression ,
725
724
Result);
726
725
}
727
726
@@ -1436,7 +1435,7 @@ bool needsComdatForCounter(const GlobalObject &GO, const Module &M) {
1436
1435
1437
1436
// Check if INSTR_PROF_RAW_VERSION_VAR is defined.
1438
1437
bool isIRPGOFlagSet (const Module *M) {
1439
- auto IRInstrVar =
1438
+ const GlobalVariable * IRInstrVar =
1440
1439
M->getNamedGlobal (INSTR_PROF_QUOTE (INSTR_PROF_RAW_VERSION_VAR));
1441
1440
if (!IRInstrVar || IRInstrVar->hasLocalLinkage ())
1442
1441
return false ;
@@ -1500,7 +1499,7 @@ void createProfileFileNameVar(Module &M, StringRef InstrProfileOutput) {
1500
1499
Error OverlapStats::accumulateCounts (const std::string &BaseFilename,
1501
1500
const std::string &TestFilename,
1502
1501
bool IsCS) {
1503
- auto getProfileSum = [IsCS](const std::string &Filename,
1502
+ auto GetProfileSum = [IsCS](const std::string &Filename,
1504
1503
CountSumOrPercent &Sum) -> Error {
1505
1504
// This function is only used from llvm-profdata that doesn't use any kind
1506
1505
// of VFS. Just create a default RealFileSystem to read profiles.
@@ -1513,10 +1512,10 @@ Error OverlapStats::accumulateCounts(const std::string &BaseFilename,
1513
1512
Reader->accumulateCounts (Sum, IsCS);
1514
1513
return Error::success ();
1515
1514
};
1516
- auto Ret = getProfileSum (BaseFilename, Base);
1515
+ auto Ret = GetProfileSum (BaseFilename, Base);
1517
1516
if (Ret)
1518
1517
return Ret;
1519
- Ret = getProfileSum (TestFilename, Test);
1518
+ Ret = GetProfileSum (TestFilename, Test);
1520
1519
if (Ret)
1521
1520
return Ret;
1522
1521
this ->BaseFilename = &BaseFilename;
0 commit comments