Skip to content

Commit 61423a9

Browse files
committed
rebase
Created using spr 1.3.4
2 parents d7219d2 + 211efe9 commit 61423a9

File tree

914 files changed

+99301
-51474
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

914 files changed

+99301
-51474
lines changed

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ class BinaryFunction {
142142
/// Types of profile the function can use. Could be a combination.
143143
enum {
144144
PF_NONE = 0, /// No profile.
145-
PF_LBR = 1, /// Profile is based on last branch records.
146-
PF_IP = 2, /// Non-LBR sample-based profile.
145+
PF_BRANCH = 1, /// Profile is based on branches or branch stacks.
146+
PF_BASIC = 2, /// Non-branch IP sample-based profile.
147147
PF_MEMEVENT = 4, /// Profile has mem events.
148148
};
149149

bolt/include/bolt/Profile/ProfileYAMLMapping.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ LLVM_YAML_STRONG_TYPEDEF(uint16_t, PROFILE_PF)
230230

231231
template <> struct ScalarBitSetTraits<PROFILE_PF> {
232232
static void bitset(IO &io, PROFILE_PF &value) {
233-
io.bitSetCase(value, "lbr", BinaryFunction::PF_LBR);
234-
io.bitSetCase(value, "sample", BinaryFunction::PF_IP);
233+
io.bitSetCase(value, "lbr", BinaryFunction::PF_BRANCH);
234+
io.bitSetCase(value, "sample", BinaryFunction::PF_BASIC);
235235
io.bitSetCase(value, "memevent", BinaryFunction::PF_MEMEVENT);
236236
}
237237
};

bolt/lib/Core/BinaryFunctionProfile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void BinaryFunction::postProcessProfile() {
7070
return;
7171
}
7272

73-
if (!(getProfileFlags() & PF_LBR))
73+
if (!(getProfileFlags() & PF_BRANCH))
7474
return;
7575

7676
// If we have at least some branch data for the function indicate that it

bolt/lib/Passes/MCF.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,15 +458,15 @@ void EstimateEdgeCounts::runOnFunction(BinaryFunction &BF) {
458458
Error EstimateEdgeCounts::runOnFunctions(BinaryContext &BC) {
459459
if (llvm::none_of(llvm::make_second_range(BC.getBinaryFunctions()),
460460
[](const BinaryFunction &BF) {
461-
return BF.getProfileFlags() == BinaryFunction::PF_IP;
461+
return BF.getProfileFlags() == BinaryFunction::PF_BASIC;
462462
}))
463463
return Error::success();
464464

465465
ParallelUtilities::WorkFuncTy WorkFun = [&](BinaryFunction &BF) {
466466
runOnFunction(BF);
467467
};
468468
ParallelUtilities::PredicateTy SkipFunc = [&](const BinaryFunction &BF) {
469-
return BF.getProfileFlags() != BinaryFunction::PF_IP;
469+
return BF.getProfileFlags() != BinaryFunction::PF_BASIC;
470470
};
471471

472472
ParallelUtilities::runOnEachFunction(

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -566,11 +566,11 @@ void DataAggregator::processProfile(BinaryContext &BC) {
566566
for (auto &BFI : BC.getBinaryFunctions()) {
567567
BinaryFunction &BF = BFI.second;
568568
if (FuncBranchData *FBD = getBranchData(BF)) {
569-
BF.markProfiled(BinaryFunction::PF_LBR);
569+
BF.markProfiled(BinaryFunction::PF_BRANCH);
570570
BF.RawSampleCount = FBD->getNumExecutedBranches();
571571
} else if (FuncBasicSampleData *FSD =
572572
getFuncBasicSampleData(BF.getNames())) {
573-
BF.markProfiled(BinaryFunction::PF_IP);
573+
BF.markProfiled(BinaryFunction::PF_BASIC);
574574
BF.RawSampleCount = FSD->getSamples();
575575
}
576576
}
@@ -1212,8 +1212,8 @@ std::error_code DataAggregator::parseAggregatedLBREntry() {
12121212
ErrorOr<StringRef> TypeOrErr = parseString(FieldSeparator);
12131213
if (std::error_code EC = TypeOrErr.getError())
12141214
return EC;
1215-
enum TType { TRACE, BRANCH, FT, FT_EXTERNAL_ORIGIN, INVALID };
1216-
auto Type = StringSwitch<TType>(TypeOrErr.get())
1215+
enum AggregatedLBREntry { TRACE, BRANCH, FT, FT_EXTERNAL_ORIGIN, INVALID };
1216+
auto Type = StringSwitch<AggregatedLBREntry>(TypeOrErr.get())
12171217
.Case("T", TRACE)
12181218
.Case("B", BRANCH)
12191219
.Case("F", FT)
@@ -1237,7 +1237,7 @@ std::error_code DataAggregator::parseAggregatedLBREntry() {
12371237
return EC;
12381238

12391239
ErrorOr<Location> TraceFtEnd = std::error_code();
1240-
if (Type == TRACE) {
1240+
if (Type == AggregatedLBREntry::TRACE) {
12411241
while (checkAndConsumeFS()) {
12421242
}
12431243
TraceFtEnd = parseLocationOrOffset();
@@ -1247,12 +1247,13 @@ std::error_code DataAggregator::parseAggregatedLBREntry() {
12471247

12481248
while (checkAndConsumeFS()) {
12491249
}
1250-
ErrorOr<int64_t> Frequency = parseNumberField(FieldSeparator, Type != BRANCH);
1250+
ErrorOr<int64_t> Frequency =
1251+
parseNumberField(FieldSeparator, Type != AggregatedLBREntry::BRANCH);
12511252
if (std::error_code EC = Frequency.getError())
12521253
return EC;
12531254

12541255
uint64_t Mispreds = 0;
1255-
if (Type == BRANCH) {
1256+
if (Type == AggregatedLBREntry::BRANCH) {
12561257
while (checkAndConsumeFS()) {
12571258
}
12581259
ErrorOr<int64_t> MispredsOrErr = parseNumberField(FieldSeparator, true);
@@ -2223,8 +2224,8 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
22232224
for (const StringMapEntry<std::nullopt_t> &EventEntry : EventNames)
22242225
EventNamesOS << LS << EventEntry.first().str();
22252226

2226-
BP.Header.Flags =
2227-
opts::BasicAggregation ? BinaryFunction::PF_IP : BinaryFunction::PF_LBR;
2227+
BP.Header.Flags = opts::BasicAggregation ? BinaryFunction::PF_BASIC
2228+
: BinaryFunction::PF_BRANCH;
22282229

22292230
// Add probe inline tree nodes.
22302231
YAMLProfileWriter::InlineTreeDesc InlineTree;

bolt/lib/Profile/DataReader.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,12 @@ void DataReader::readProfile(BinaryFunction &BF) {
358358
return;
359359

360360
if (!hasLBR()) {
361-
BF.ProfileFlags = BinaryFunction::PF_IP;
361+
BF.ProfileFlags = BinaryFunction::PF_BASIC;
362362
readBasicSampleData(BF);
363363
return;
364364
}
365365

366-
BF.ProfileFlags = BinaryFunction::PF_LBR;
366+
BF.ProfileFlags = BinaryFunction::PF_BRANCH;
367367

368368
// Possibly assign/re-assign branch profile data.
369369
matchProfileData(BF);
@@ -1035,9 +1035,8 @@ ErrorOr<BasicSampleInfo> DataReader::parseSampleInfo() {
10351035
}
10361036

10371037
ErrorOr<bool> DataReader::maybeParseNoLBRFlag() {
1038-
if (ParsingBuf.size() < 6 || ParsingBuf.substr(0, 6) != "no_lbr")
1038+
if (!ParsingBuf.consume_front("no_lbr"))
10391039
return false;
1040-
ParsingBuf = ParsingBuf.drop_front(6);
10411040
Col += 6;
10421041

10431042
if (ParsingBuf.size() > 0 && ParsingBuf[0] == ' ')
@@ -1058,9 +1057,8 @@ ErrorOr<bool> DataReader::maybeParseNoLBRFlag() {
10581057
}
10591058

10601059
ErrorOr<bool> DataReader::maybeParseBATFlag() {
1061-
if (ParsingBuf.size() < 16 || ParsingBuf.substr(0, 16) != "boltedcollection")
1060+
if (!ParsingBuf.consume_front("boltedcollection"))
10621061
return false;
1063-
ParsingBuf = ParsingBuf.drop_front(16);
10641062
Col += 16;
10651063

10661064
if (!checkAndConsumeNewLine()) {

bolt/lib/Profile/YAMLProfileReader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ bool YAMLProfileReader::parseFunctionProfile(
221221

222222
// Basic samples profile (without LBR) does not have branches information
223223
// and needs a special processing.
224-
if (YamlBP.Header.Flags & BinaryFunction::PF_IP) {
224+
if (YamlBP.Header.Flags & BinaryFunction::PF_BASIC) {
225225
if (!YamlBB.EventCount) {
226226
BB.setExecutionCount(0);
227227
continue;
@@ -338,7 +338,7 @@ bool YAMLProfileReader::parseFunctionProfile(
338338
if (BB.getExecutionCount() == BinaryBasicBlock::COUNT_NO_PROFILE)
339339
BB.setExecutionCount(0);
340340

341-
if (YamlBP.Header.Flags & BinaryFunction::PF_IP)
341+
if (YamlBP.Header.Flags & BinaryFunction::PF_BASIC)
342342
BF.setExecutionCount(FunctionExecutionCount);
343343

344344
ProfileMatched &= !MismatchedBlocks && !MismatchedCalls && !MismatchedEdges;

bolt/lib/Profile/YAMLProfileWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ YAMLProfileWriter::convert(const BinaryFunction &BF, bool UseDFS,
215215
const MCPseudoProbeDecoder *PseudoProbeDecoder =
216216
opts::ProfileWritePseudoProbes ? BC.getPseudoProbeDecoder() : nullptr;
217217

218-
const uint16_t LBRProfile = BF.getProfileFlags() & BinaryFunction::PF_LBR;
218+
const uint16_t LBRProfile = BF.getProfileFlags() & BinaryFunction::PF_BRANCH;
219219

220220
// Prepare function and block hashes
221221
BF.computeHash(UseDFS);

bolt/lib/Rewrite/BuildIDRewriter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ Error BuildIDRewriter::sectionInitializer() {
7878
"out of bounds while reading note section: %s",
7979
toString(Cursor.takeError()).c_str());
8080

81-
if (Type == ELF::NT_GNU_BUILD_ID && Name.substr(0, 3) == "GNU" &&
82-
DescSz) {
81+
if (Type == ELF::NT_GNU_BUILD_ID && Name.starts_with("GNU") && DescSz) {
8382
BuildIDSection = NoteSection;
8483
BuildID = Desc;
8584
BC.setFileBuildID(getPrintableBuildID(Desc));

bolt/tools/merge-fdata/merge-fdata.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ void mergeProfileHeaders(BinaryProfileHeader &MergedHeader,
124124
if (!MergedHeader.Flags)
125125
MergedHeader.Flags = Header.Flags;
126126

127-
constexpr auto Mask =
128-
llvm::bolt::BinaryFunction::PF_LBR | llvm::bolt::BinaryFunction::PF_IP;
127+
constexpr auto Mask = llvm::bolt::BinaryFunction::PF_BRANCH |
128+
llvm::bolt::BinaryFunction::PF_BASIC;
129129
if ((MergedHeader.Flags & Mask) != (Header.Flags & Mask)) {
130130
errs() << "ERROR: cannot merge LBR profile with non-LBR profile\n";
131131
exit(1);

0 commit comments

Comments
 (0)