@@ -66,8 +66,8 @@ inline std::error_code make_error_code(sampleprof_error E) {
66
66
return std::error_code (static_cast <int >(E), sampleprof_category ());
67
67
}
68
68
69
- inline sampleprof_error MergeResult (sampleprof_error &Accumulator,
70
- sampleprof_error Result) {
69
+ inline sampleprof_error mergeSampleProfErrors (sampleprof_error &Accumulator,
70
+ sampleprof_error Result) {
71
71
// Prefer first error encountered as later errors may be secondary effects of
72
72
// the initial problem.
73
73
if (Accumulator == sampleprof_error::success &&
@@ -129,7 +129,7 @@ enum SecType {
129
129
};
130
130
131
131
static inline std::string getSecName (SecType Type) {
132
- switch (( int ) Type) { // Avoid -Wcovered-switch-default
132
+ switch (static_cast < int >( Type) ) { // Avoid -Wcovered-switch-default
133
133
case SecInValid:
134
134
return " InvalidSection" ;
135
135
case SecProfSummary:
@@ -392,7 +392,7 @@ class SampleRecord {
392
392
uint64_t getSamples () const { return NumSamples; }
393
393
const CallTargetMap &getCallTargets () const { return CallTargets; }
394
394
const SortedCallTargetSet getSortedCallTargets () const {
395
- return SortCallTargets (CallTargets);
395
+ return sortCallTargets (CallTargets);
396
396
}
397
397
398
398
uint64_t getCallTargetSum () const {
@@ -403,7 +403,8 @@ class SampleRecord {
403
403
}
404
404
405
405
// / Sort call targets in descending order of call frequency.
406
- static const SortedCallTargetSet SortCallTargets (const CallTargetMap &Targets) {
406
+ static const SortedCallTargetSet
407
+ sortCallTargets (const CallTargetMap &Targets) {
407
408
SortedCallTargetSet SortedTargets;
408
409
for (const auto &[Target, Frequency] : Targets) {
409
410
SortedTargets.emplace (Target, Frequency);
@@ -642,8 +643,8 @@ class SampleContext {
642
643
}
643
644
644
645
// / Set the name of the function and clear the current context.
645
- void setFunction (FunctionId newFunction ) {
646
- Func = newFunction ;
646
+ void setFunction (FunctionId NewFunctionID ) {
647
+ Func = NewFunctionID ;
647
648
FullContext = SampleContextFrames ();
648
649
State = UnknownContext;
649
650
}
@@ -692,7 +693,7 @@ class SampleContext {
692
693
}
693
694
};
694
695
695
- bool IsPrefixOf (const SampleContext &That) const {
696
+ bool isPrefixOf (const SampleContext &That) const {
696
697
auto ThisContext = FullContext;
697
698
auto ThatContext = That.FullContext ;
698
699
if (ThatContext.size () < ThisContext.size ())
@@ -846,11 +847,11 @@ class FunctionSamples {
846
847
}
847
848
848
849
// Set current context and all callee contexts to be synthetic.
849
- void SetContextSynthetic () {
850
+ void setContextSynthetic () {
850
851
Context.setState (SyntheticContext);
851
852
for (auto &I : CallsiteSamples) {
852
853
for (auto &CS : I.second ) {
853
- CS.second .SetContextSynthetic ();
854
+ CS.second .setContextSynthetic ();
854
855
}
855
856
}
856
857
}
@@ -864,32 +865,31 @@ class FunctionSamples {
864
865
const auto &ProfileLoc = IRToProfileLocationMap->find (IRLoc);
865
866
if (ProfileLoc != IRToProfileLocationMap->end ())
866
867
return ProfileLoc->second ;
867
- else
868
- return IRLoc;
868
+ return IRLoc;
869
869
}
870
870
871
871
// / Return the number of samples collected at the given location.
872
872
// / Each location is specified by \p LineOffset and \p Discriminator.
873
873
// / If the location is not found in profile, return error.
874
874
ErrorOr<uint64_t > findSamplesAt (uint32_t LineOffset,
875
875
uint32_t Discriminator) const {
876
- const auto &ret = BodySamples.find (
876
+ const auto &Ret = BodySamples.find (
877
877
mapIRLocToProfileLoc (LineLocation (LineOffset, Discriminator)));
878
- if (ret == BodySamples.end ())
878
+ if (Ret == BodySamples.end ())
879
879
return std::error_code ();
880
- return ret ->second .getSamples ();
880
+ return Ret ->second .getSamples ();
881
881
}
882
882
883
883
// / Returns the call target map collected at a given location.
884
884
// / Each location is specified by \p LineOffset and \p Discriminator.
885
885
// / If the location is not found in profile, return error.
886
886
ErrorOr<const SampleRecord::CallTargetMap &>
887
887
findCallTargetMapAt (uint32_t LineOffset, uint32_t Discriminator) const {
888
- const auto &ret = BodySamples.find (
888
+ const auto &Ret = BodySamples.find (
889
889
mapIRLocToProfileLoc (LineLocation (LineOffset, Discriminator)));
890
- if (ret == BodySamples.end ())
890
+ if (Ret == BodySamples.end ())
891
891
return std::error_code ();
892
- return ret ->second .getCallTargets ();
892
+ return Ret ->second .getCallTargets ();
893
893
}
894
894
895
895
// / Returns the call target map collected at a given location specified by \p
@@ -910,10 +910,10 @@ class FunctionSamples {
910
910
// / Returns the FunctionSamplesMap at the given \p Loc.
911
911
const FunctionSamplesMap *
912
912
findFunctionSamplesMapAt (const LineLocation &Loc) const {
913
- auto iter = CallsiteSamples.find (mapIRLocToProfileLoc (Loc));
914
- if (iter == CallsiteSamples.end ())
913
+ auto Iter = CallsiteSamples.find (mapIRLocToProfileLoc (Loc));
914
+ if (Iter == CallsiteSamples.end ())
915
915
return nullptr ;
916
- return &iter ->second ;
916
+ return &Iter ->second ;
917
917
}
918
918
919
919
// / Returns a pointer to FunctionSamples at the given callsite location
@@ -960,8 +960,8 @@ class FunctionSamples {
960
960
else if (!CallsiteSamples.empty ()) {
961
961
// An indirect callsite may be promoted to several inlined direct calls.
962
962
// We need to get the sum of them.
963
- for (const auto &N_FS : CallsiteSamples.begin ()->second )
964
- Count += N_FS .second .getHeadSamplesEstimate ();
963
+ for (const auto &FuncSamples : CallsiteSamples.begin ()->second )
964
+ Count += FuncSamples .second .getHeadSamplesEstimate ();
965
965
}
966
966
// Return at least 1 if total sample is not 0.
967
967
return Count ? Count : TotalSamples > 0 ;
@@ -1013,18 +1013,21 @@ class FunctionSamples {
1013
1013
return sampleprof_error::hash_mismatch;
1014
1014
}
1015
1015
1016
- MergeResult (Result, addTotalSamples (Other.getTotalSamples (), Weight));
1017
- MergeResult (Result, addHeadSamples (Other.getHeadSamples (), Weight));
1016
+ mergeSampleProfErrors (Result,
1017
+ addTotalSamples (Other.getTotalSamples (), Weight));
1018
+ mergeSampleProfErrors (Result,
1019
+ addHeadSamples (Other.getHeadSamples (), Weight));
1018
1020
for (const auto &I : Other.getBodySamples ()) {
1019
1021
const LineLocation &Loc = I.first ;
1020
1022
const SampleRecord &Rec = I.second ;
1021
- MergeResult (Result, BodySamples[Loc].merge (Rec, Weight));
1023
+ mergeSampleProfErrors (Result, BodySamples[Loc].merge (Rec, Weight));
1022
1024
}
1023
1025
for (const auto &I : Other.getCallsiteSamples ()) {
1024
1026
const LineLocation &Loc = I.first ;
1025
1027
FunctionSamplesMap &FSMap = functionSamplesAt (Loc);
1026
1028
for (const auto &Rec : I.second )
1027
- MergeResult (Result, FSMap[Rec.first ].merge (Rec.second , Weight));
1029
+ mergeSampleProfErrors (Result,
1030
+ FSMap[Rec.first ].merge (Rec.second , Weight));
1028
1031
}
1029
1032
return Result;
1030
1033
}
@@ -1039,10 +1042,10 @@ class FunctionSamples {
1039
1042
uint64_t Threshold) const {
1040
1043
if (TotalSamples <= Threshold)
1041
1044
return ;
1042
- auto isDeclaration = [](const Function *F) {
1045
+ auto IsDeclaration = [](const Function *F) {
1043
1046
return !F || F->isDeclaration ();
1044
1047
};
1045
- if (isDeclaration (SymbolMap.lookup (getFunction ()))) {
1048
+ if (IsDeclaration (SymbolMap.lookup (getFunction ()))) {
1046
1049
// Add to the import list only when it's defined out of module.
1047
1050
S.insert (getGUID ());
1048
1051
}
@@ -1052,7 +1055,7 @@ class FunctionSamples {
1052
1055
for (const auto &TS : BS.second .getCallTargets ())
1053
1056
if (TS.second > Threshold) {
1054
1057
const Function *Callee = SymbolMap.lookup (TS.first );
1055
- if (isDeclaration (Callee))
1058
+ if (IsDeclaration (Callee))
1056
1059
S.insert (TS.first .getHashCode ());
1057
1060
}
1058
1061
for (const auto &CS : CallsiteSamples)
@@ -1061,8 +1064,8 @@ class FunctionSamples {
1061
1064
}
1062
1065
1063
1066
// / Set the name of the function.
1064
- void setFunction (FunctionId newFunction ) {
1065
- Context.setFunction (newFunction );
1067
+ void setFunction (FunctionId NewFunctionID ) {
1068
+ Context.setFunction (NewFunctionID );
1066
1069
}
1067
1070
1068
1071
// / Return the function name.
@@ -1083,7 +1086,7 @@ class FunctionSamples {
1083
1086
// / Return the canonical name for a function, taking into account
1084
1087
// / suffix elision policy attributes.
1085
1088
static StringRef getCanonicalFnName (const Function &F) {
1086
- auto AttrName = " sample-profile-suffix-elision-policy" ;
1089
+ const char * AttrName = " sample-profile-suffix-elision-policy" ;
1087
1090
auto Attr = F.getFnAttribute (AttrName).getValueAsString ();
1088
1091
return getCanonicalFnName (F.getName (), Attr);
1089
1092
}
@@ -1099,12 +1102,12 @@ class FunctionSamples {
1099
1102
// Note the sequence of the suffixes in the knownSuffixes array matters.
1100
1103
// If suffix "A" is appended after the suffix "B", "A" should be in front
1101
1104
// of "B" in knownSuffixes.
1102
- const char *knownSuffixes [] = {LLVMSuffix, PartSuffix, UniqSuffix};
1103
- if (Attr == " " || Attr == " all" ) {
1105
+ const char *KnownSuffixes [] = {LLVMSuffix, PartSuffix, UniqSuffix};
1106
+ if (Attr == " " || Attr == " all" )
1104
1107
return FnName.split (' .' ).first ;
1105
- } else if (Attr == " selected" ) {
1108
+ if (Attr == " selected" ) {
1106
1109
StringRef Cand (FnName);
1107
- for (const auto &Suf : knownSuffixes ) {
1110
+ for (const auto &Suf : KnownSuffixes ) {
1108
1111
StringRef Suffix (Suf);
1109
1112
// If the profile contains ".__uniq." suffix, don't strip the
1110
1113
// suffix for names in the IR.
@@ -1118,11 +1121,10 @@ class FunctionSamples {
1118
1121
Cand = Cand.substr (0 , It);
1119
1122
}
1120
1123
return Cand;
1121
- } else if (Attr == " none" ) {
1122
- return FnName;
1123
- } else {
1124
- assert (false && " internal error: unknown suffix elision policy" );
1125
1124
}
1125
+ if (Attr == " none" )
1126
+ return FnName;
1127
+ assert (false && " internal error: unknown suffix elision policy" );
1126
1128
return FnName;
1127
1129
}
1128
1130
@@ -1307,7 +1309,7 @@ class SampleProfileMap
1307
1309
public:
1308
1310
// Convenience method because this is being used in many places. Set the
1309
1311
// FunctionSamples' context if its newly inserted.
1310
- mapped_type &Create (const SampleContext &Ctx) {
1312
+ mapped_type &create (const SampleContext &Ctx) {
1311
1313
auto Ret = try_emplace (Ctx, FunctionSamples ());
1312
1314
if (Ret.second )
1313
1315
Ret.first ->second .setContext (Ctx);
@@ -1428,7 +1430,7 @@ class ProfileConverter {
1428
1430
for (const auto &I : InputProfiles) {
1429
1431
// Retain the profile name and clear the full context for each function
1430
1432
// profile.
1431
- FunctionSamples &FS = OutputProfiles.Create (I.second .getFunction ());
1433
+ FunctionSamples &FS = OutputProfiles.create (I.second .getFunction ());
1432
1434
FS.merge (I.second );
1433
1435
}
1434
1436
} else {
@@ -1507,8 +1509,8 @@ class ProfileSymbolList {
1507
1509
public:
1508
1510
// / copy indicates whether we need to copy the underlying memory
1509
1511
// / for the input Name.
1510
- void add (StringRef Name, bool copy = false ) {
1511
- if (!copy ) {
1512
+ void add (StringRef Name, bool Copy = false ) {
1513
+ if (!Copy ) {
1512
1514
Syms.insert (Name);
1513
1515
return ;
1514
1516
}
0 commit comments