Skip to content

Commit 2f14b17

Browse files
committed
[𝘀𝗽𝗿] changes introduced through rebase
Created using spr 1.3.6-beta.1 [skip ci]
2 parents fc58910 + a4186bd commit 2f14b17

File tree

802 files changed

+97101
-50938
lines changed

Some content is hidden

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

802 files changed

+97101
-50938
lines changed

bolt/include/bolt/Profile/DataReader.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ struct FuncSampleData {
246246
/// Get the number of samples recorded in [Start, End)
247247
uint64_t getSamples(uint64_t Start, uint64_t End) const;
248248

249+
/// Returns the total number of samples recorded in this function.
250+
uint64_t getSamples() const;
251+
249252
/// Aggregation helper
250253
DenseMap<uint64_t, size_t> Index;
251254

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -565,15 +565,14 @@ void DataAggregator::processProfile(BinaryContext &BC) {
565565
processMemEvents();
566566

567567
// Mark all functions with registered events as having a valid profile.
568-
const auto Flags = opts::BasicAggregation ? BinaryFunction::PF_SAMPLE
569-
: BinaryFunction::PF_LBR;
570568
for (auto &BFI : BC.getBinaryFunctions()) {
571569
BinaryFunction &BF = BFI.second;
572-
FuncBranchData *FBD = getBranchData(BF);
573-
if (FBD || getFuncSampleData(BF.getNames())) {
574-
BF.markProfiled(Flags);
575-
if (FBD)
576-
BF.RawBranchCount = FBD->getNumExecutedBranches();
570+
if (FuncBranchData *FBD = getBranchData(BF)) {
571+
BF.markProfiled(BinaryFunction::PF_LBR);
572+
BF.RawBranchCount = FBD->getNumExecutedBranches();
573+
} else if (FuncSampleData *FSD = getFuncSampleData(BF.getNames())) {
574+
BF.markProfiled(BinaryFunction::PF_SAMPLE);
575+
BF.RawBranchCount = FSD->getSamples();
577576
}
578577
}
579578

@@ -630,10 +629,18 @@ StringRef DataAggregator::getLocationName(const BinaryFunction &Func,
630629

631630
bool DataAggregator::doSample(BinaryFunction &OrigFunc, uint64_t Address,
632631
uint64_t Count) {
632+
// To record executed bytes, use basic block size as is regardless of BAT.
633+
uint64_t BlockSize = 0;
634+
if (BinaryBasicBlock *BB = OrigFunc.getBasicBlockContainingOffset(
635+
Address - OrigFunc.getAddress()))
636+
BlockSize = BB->getOriginalSize();
637+
633638
BinaryFunction *ParentFunc = getBATParentFunction(OrigFunc);
634639
BinaryFunction &Func = ParentFunc ? *ParentFunc : OrigFunc;
635-
if (ParentFunc || (BAT && !BAT->isBATFunction(OrigFunc.getAddress())))
640+
if (ParentFunc || (BAT && !BAT->isBATFunction(Func.getAddress())))
636641
NumColdSamples += Count;
642+
// Attach executed bytes to parent function in case of cold fragment.
643+
Func.SampleCountInBytes += Count * BlockSize;
637644

638645
auto I = NamesToSamples.find(Func.getOneName());
639646
if (I == NamesToSamples.end()) {

bolt/lib/Profile/DataReader.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ uint64_t FuncSampleData::getSamples(uint64_t Start, uint64_t End) const {
128128
return Result;
129129
}
130130

131+
uint64_t FuncSampleData::getSamples() const {
132+
uint64_t Result = 0;
133+
for (const SampleInfo &I : Data)
134+
Result += I.Hits;
135+
return Result;
136+
}
137+
131138
void FuncSampleData::bumpCount(uint64_t Offset, uint64_t Count) {
132139
auto Iter = Index.find(Offset);
133140
if (Iter == Index.end()) {
@@ -1028,9 +1035,8 @@ ErrorOr<SampleInfo> DataReader::parseSampleInfo() {
10281035
}
10291036

10301037
ErrorOr<bool> DataReader::maybeParseNoLBRFlag() {
1031-
if (ParsingBuf.size() < 6 || ParsingBuf.substr(0, 6) != "no_lbr")
1038+
if (!ParsingBuf.consume_front("no_lbr"))
10321039
return false;
1033-
ParsingBuf = ParsingBuf.drop_front(6);
10341040
Col += 6;
10351041

10361042
if (ParsingBuf.size() > 0 && ParsingBuf[0] == ' ')
@@ -1051,9 +1057,8 @@ ErrorOr<bool> DataReader::maybeParseNoLBRFlag() {
10511057
}
10521058

10531059
ErrorOr<bool> DataReader::maybeParseBATFlag() {
1054-
if (ParsingBuf.size() < 16 || ParsingBuf.substr(0, 16) != "boltedcollection")
1060+
if (!ParsingBuf.consume_front("boltedcollection"))
10551061
return false;
1056-
ParsingBuf = ParsingBuf.drop_front(16);
10571062
Col += 16;
10581063

10591064
if (!checkAndConsumeNewLine()) {

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/test/perf2bolt/perf_test.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ RUN: perf2bolt %t -p=%t2 -o %t3 -nl -ignore-build-id 2>&1 | FileCheck %s
88

99
CHECK-NOT: PERF2BOLT-ERROR
1010
CHECK-NOT: !! WARNING !! This high mismatch ratio indicates the input binary is probably not the same binary used during profiling collection.
11+
CHECK: BOLT-INFO: Functions with density >= {{.*}} account for 99.00% total sample counts.
1112

1213
RUN: %clang %S/Inputs/perf_test.c -no-pie -fuse-ld=lld -o %t4
1314
RUN: perf record -Fmax -e cycles:u -o %t5 -- %t4

clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ namespace {
1919

2020
StringRef removeFirstSuffix(StringRef Str, ArrayRef<const char *> Suffixes) {
2121
for (StringRef Suffix : Suffixes) {
22-
if (Str.ends_with(Suffix)) {
23-
return Str.substr(0, Str.size() - Suffix.size());
24-
}
22+
if (Str.consume_back(Suffix))
23+
return Str;
2524
}
2625
return Str;
2726
}

clang-tools-extra/clangd/ClangdServer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ void ClangdServer::codeComplete(PathRef File, Position Pos,
457457
CodeCompleteOpts.ArgumentLists = Config::current().Completion.ArgumentLists;
458458
CodeCompleteOpts.InsertIncludes =
459459
Config::current().Completion.HeaderInsertion;
460+
CodeCompleteOpts.CodePatterns = Config::current().Completion.CodePatterns;
460461
// FIXME(ibiryukov): even if Preamble is non-null, we may want to check
461462
// both the old and the new version in case only one of them matches.
462463
CodeCompleteResult Result = clangd::codeComplete(

clang-tools-extra/clangd/CodeComplete.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,8 @@ struct CompletionRecorder : public CodeCompleteConsumer {
926926
// FIXME: in case there is no future sema completion callback after the
927927
// recovery mode, we might still want to provide some results (e.g. trivial
928928
// identifier-based completion).
929-
if (Context.getKind() == CodeCompletionContext::CCC_Recovery) {
929+
CodeCompletionContext::Kind ContextKind = Context.getKind();
930+
if (ContextKind == CodeCompletionContext::CCC_Recovery) {
930931
log("Code complete: Ignoring sema code complete callback with Recovery "
931932
"context.");
932933
return;
@@ -950,6 +951,12 @@ struct CompletionRecorder : public CodeCompleteConsumer {
950951
// Retain the results we might want.
951952
for (unsigned I = 0; I < NumResults; ++I) {
952953
auto &Result = InResults[I];
954+
if (Config::current().Completion.CodePatterns ==
955+
Config::CodePatternsPolicy::None &&
956+
Result.Kind == CodeCompletionResult::RK_Pattern &&
957+
// keep allowing the include files autocomplete suggestions
958+
ContextKind != CodeCompletionContext::CCC_IncludedFile)
959+
continue;
953960
// Class members that are shadowed by subclasses are usually noise.
954961
if (Result.Hidden && Result.Declaration &&
955962
Result.Declaration->isCXXClassMember())
@@ -2153,7 +2160,8 @@ class CodeCompleteFlow {
21532160

21542161
clang::CodeCompleteOptions CodeCompleteOptions::getClangCompleteOpts() const {
21552162
clang::CodeCompleteOptions Result;
2156-
Result.IncludeCodePatterns = EnableSnippets;
2163+
Result.IncludeCodePatterns =
2164+
EnableSnippets && (CodePatterns != Config::CodePatternsPolicy::None);
21572165
Result.IncludeMacros = true;
21582166
Result.IncludeGlobals = true;
21592167
// We choose to include full comments and not do doxygen parsing in

clang-tools-extra/clangd/CodeComplete.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ struct CodeCompleteOptions {
111111
Config::ArgumentListsPolicy ArgumentLists =
112112
Config::ArgumentListsPolicy::FullPlaceholders;
113113

114+
/// Whether to suggest code patterns & snippets or not in completion
115+
Config::CodePatternsPolicy CodePatterns = Config::CodePatternsPolicy::All;
116+
114117
/// Whether to use the clang parser, or fallback to text-based completion
115118
/// (using identifiers in the current file and symbol indexes).
116119
enum CodeCompletionParse {

clang-tools-extra/clangd/CompileCommands.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,7 @@ enum DriverMode : unsigned char {
404404
DriverMode getDriverMode(const std::vector<std::string> &Args) {
405405
DriverMode Mode = DM_GCC;
406406
llvm::StringRef Argv0 = Args.front();
407-
if (Argv0.ends_with_insensitive(".exe"))
408-
Argv0 = Argv0.drop_back(strlen(".exe"));
407+
Argv0.consume_back_insensitive(".exe");
409408
if (Argv0.ends_with_insensitive("cl"))
410409
Mode = DM_CL;
411410
for (const llvm::StringRef Arg : Args) {

0 commit comments

Comments
 (0)