Skip to content

Commit c2f27b3

Browse files
necipfazilPrabhuk
authored andcommitted
[𝘀𝗽𝗿] changes introduced through rebase
Created using spr 1.3.6-beta.1 [skip ci]
2 parents 3065b9b + 56e4111 commit c2f27b3

File tree

2,340 files changed

+262635
-118070
lines changed

Some content is hidden

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

2,340 files changed

+262635
-118070
lines changed

.ci/generate-buildkite-pipeline-premerge

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function add-dependencies() {
9191
echo "${project}"
9292
case ${project} in
9393
bolt)
94-
for p in lld llvm; do
94+
for p in clang lld llvm; do
9595
echo $p
9696
done
9797
;;

.ci/monolithic-linux.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
4848
-D LLVM_LIT_ARGS="-v --xunit-xml-output ${BUILD_DIR}/test-results.xml --timeout=1200 --time-tests" \
4949
-D LLVM_ENABLE_LLD=ON \
5050
-D CMAKE_CXX_FLAGS=-gmlt \
51-
-D BOLT_CLANG_EXE=/usr/bin/clang \
5251
-D LLVM_CCACHE_BUILD=ON \
5352
-D MLIR_ENABLE_BINDINGS_PYTHON=ON
5453

.github/CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
clang/lib/AST/Interp/ @tbaederr
3636
clang/test/AST/Interp/ @tbaederr
3737

38+
/clang/include/clang/CIR @lanza @bcardosolopes
39+
/clang/lib/CIR @lanza @bcardosolopes
40+
/clang/tools/cir-* @lanza @bcardosolopes
41+
3842
/lldb/ @JDevlieghere
3943

4044
# MLIR Interfaces.

.github/new-prs-labeler.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
BOLT:
2+
- bolt/**/*
3+
14
ClangIR:
25
- clang/include/clang/CIR/**/*
36
- clang/lib/CIR/**/*
@@ -467,6 +470,7 @@ backend:m68k:
467470

468471
libc++:
469472
- libcxx/**
473+
- .github/workflows/libcxx-*
470474

471475
libc++abi:
472476
- libcxxabi/**

bolt/include/bolt/Passes/BinaryPasses.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,7 @@ class PrintProfileStats : public BinaryFunctionPass {
400400
/// dyno stats categories.
401401
class PrintProgramStats : public BinaryFunctionPass {
402402
public:
403-
explicit PrintProgramStats(const cl::opt<bool> &PrintPass)
404-
: BinaryFunctionPass(PrintPass) {}
403+
explicit PrintProgramStats() : BinaryFunctionPass(false) {}
405404

406405
const char *getName() const override { return "print-stats"; }
407406
bool shouldPrint(const BinaryFunction &) const override { return false; }

bolt/include/bolt/Profile/DataAggregator.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,8 @@ class DataAggregator : public DataReader {
198198
/// A trace is region of code executed between two LBR entries supplied in
199199
/// execution order.
200200
///
201-
/// Return true if the trace is valid, false otherwise.
202-
bool
203-
recordTrace(BinaryFunction &BF, const LBREntry &First, const LBREntry &Second,
204-
uint64_t Count,
205-
SmallVector<std::pair<uint64_t, uint64_t>, 16> &Branches) const;
206-
207201
/// Return a vector of offsets corresponding to a trace in a function
208-
/// (see recordTrace() above).
202+
/// if the trace is valid, std::nullopt otherwise.
209203
std::optional<SmallVector<std::pair<uint64_t, uint64_t>, 16>>
210204
getFallthroughsInTrace(BinaryFunction &BF, const LBREntry &First,
211205
const LBREntry &Second, uint64_t Count = 1) const;

bolt/include/bolt/Rewrite/RewriteInstance.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,18 @@ class RewriteInstance {
422422
/// Section name used for extra BOLT code in addition to .text.
423423
static StringRef getBOLTTextSectionName() { return ".bolt.text"; }
424424

425+
/// Symbol markers for BOLT reserved area.
426+
static StringRef getBOLTReservedStart() { return "__bolt_reserved_start"; }
427+
static StringRef getBOLTReservedEnd() { return "__bolt_reserved_end"; }
428+
425429
/// Common section names.
426430
static StringRef getEHFrameSectionName() { return ".eh_frame"; }
431+
static StringRef getEHFrameHdrSectionName() { return ".eh_frame_hdr"; }
427432
static StringRef getRelaDynSectionName() { return ".rela.dyn"; }
428433

434+
/// FILE symbol name used for local fragments of global functions.
435+
static StringRef getBOLTFileSymbolName() { return "bolt-pseudo.o"; }
436+
429437
/// An instance of the input binary we are processing, externally owned.
430438
llvm::object::ELFObjectFileBase *InputFile;
431439

@@ -490,6 +498,9 @@ class RewriteInstance {
490498
/// Store all non-zero symbols in this map for a quick address lookup.
491499
std::map<uint64_t, llvm::object::SymbolRef> FileSymRefs;
492500

501+
/// FILE symbols used for disambiguating split function parents.
502+
std::vector<ELFSymbolRef> FileSymbols;
503+
493504
std::unique_ptr<DWARFRewriter> DebugInfoRewriter;
494505

495506
std::unique_ptr<BoltAddressTranslation> BAT;

bolt/include/bolt/Utils/NameResolver.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,23 @@ class NameResolver {
2828
static constexpr char Sep = '/';
2929

3030
public:
31-
/// Return unique version of the \p Name in the form "Name<Sep><Number>".
31+
/// Return the number of uniquified versions of a given \p Name.
32+
uint64_t getUniquifiedNameCount(StringRef Name) const {
33+
if (Counters.contains(Name))
34+
return Counters.at(Name);
35+
return 0;
36+
}
37+
38+
/// Return unique version of the \p Name in the form "Name<Sep><ID>".
39+
std::string getUniqueName(StringRef Name, const uint64_t ID) const {
40+
return (Name + Twine(Sep) + Twine(ID)).str();
41+
}
42+
43+
/// Register new version of \p Name and return unique version in the form
44+
/// "Name<Sep><Number>".
3245
std::string uniquify(StringRef Name) {
3346
const uint64_t ID = ++Counters[Name];
34-
return (Name + Twine(Sep) + Twine(ID)).str();
47+
return getUniqueName(Name, ID);
3548
}
3649

3750
/// For uniquified \p Name, return the original form (that may no longer be

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "bolt/Profile/DataAggregator.h"
1515
#include "bolt/Core/BinaryContext.h"
1616
#include "bolt/Core/BinaryFunction.h"
17+
#include "bolt/Passes/BinaryPasses.h"
1718
#include "bolt/Profile/BoltAddressTranslation.h"
1819
#include "bolt/Profile/Heatmap.h"
1920
#include "bolt/Profile/YAMLProfileWriter.h"
@@ -611,6 +612,7 @@ Error DataAggregator::readProfile(BinaryContext &BC) {
611612
if (std::error_code EC = writeBATYAML(BC, opts::SaveProfile))
612613
report_error("cannot create output data file", EC);
613614
}
615+
BC.logBOLTErrorsAndQuitOnFatal(PrintProgramStats().runOnFunctions(BC));
614616
}
615617

616618
return Error::success();
@@ -859,14 +861,17 @@ bool DataAggregator::doTrace(const LBREntry &First, const LBREntry &Second,
859861
return true;
860862
}
861863

862-
bool DataAggregator::recordTrace(
863-
BinaryFunction &BF, const LBREntry &FirstLBR, const LBREntry &SecondLBR,
864-
uint64_t Count,
865-
SmallVector<std::pair<uint64_t, uint64_t>, 16> &Branches) const {
864+
std::optional<SmallVector<std::pair<uint64_t, uint64_t>, 16>>
865+
DataAggregator::getFallthroughsInTrace(BinaryFunction &BF,
866+
const LBREntry &FirstLBR,
867+
const LBREntry &SecondLBR,
868+
uint64_t Count) const {
869+
SmallVector<std::pair<uint64_t, uint64_t>, 16> Branches;
870+
866871
BinaryContext &BC = BF.getBinaryContext();
867872

868873
if (!BF.isSimple())
869-
return false;
874+
return std::nullopt;
870875

871876
assert(BF.hasCFG() && "can only record traces in CFG state");
872877

@@ -875,13 +880,13 @@ bool DataAggregator::recordTrace(
875880
const uint64_t To = SecondLBR.From - BF.getAddress();
876881

877882
if (From > To)
878-
return false;
883+
return std::nullopt;
879884

880885
const BinaryBasicBlock *FromBB = BF.getBasicBlockContainingOffset(From);
881886
const BinaryBasicBlock *ToBB = BF.getBasicBlockContainingOffset(To);
882887

883888
if (!FromBB || !ToBB)
884-
return false;
889+
return std::nullopt;
885890

886891
// Adjust FromBB if the first LBR is a return from the last instruction in
887892
// the previous block (that instruction should be a call).
@@ -905,7 +910,7 @@ bool DataAggregator::recordTrace(
905910
// within the same basic block, e.g. when two call instructions are in the
906911
// same block. In this case we skip the processing.
907912
if (FromBB == ToBB)
908-
return true;
913+
return Branches;
909914

910915
// Process blocks in the original layout order.
911916
BinaryBasicBlock *BB = BF.getLayout().getBlock(FromBB->getIndex());
@@ -919,7 +924,7 @@ bool DataAggregator::recordTrace(
919924
LLVM_DEBUG(dbgs() << "no fall-through for the trace:\n"
920925
<< " " << FirstLBR << '\n'
921926
<< " " << SecondLBR << '\n');
922-
return false;
927+
return std::nullopt;
923928
}
924929

925930
const MCInst *Instr = BB->getLastNonPseudoInstr();
@@ -943,20 +948,7 @@ bool DataAggregator::recordTrace(
943948
BI.Count += Count;
944949
}
945950

946-
return true;
947-
}
948-
949-
std::optional<SmallVector<std::pair<uint64_t, uint64_t>, 16>>
950-
DataAggregator::getFallthroughsInTrace(BinaryFunction &BF,
951-
const LBREntry &FirstLBR,
952-
const LBREntry &SecondLBR,
953-
uint64_t Count) const {
954-
SmallVector<std::pair<uint64_t, uint64_t>, 16> Res;
955-
956-
if (!recordTrace(BF, FirstLBR, SecondLBR, Count, Res))
957-
return std::nullopt;
958-
959-
return Res;
951+
return Branches;
960952
}
961953

962954
bool DataAggregator::recordEntry(BinaryFunction &BF, uint64_t To, bool Mispred,

bolt/lib/Rewrite/BinaryPassManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ Error BinaryFunctionPassManager::runAllPasses(BinaryContext &BC) {
356356
// order they're registered.
357357

358358
// Run this pass first to use stats for the original functions.
359-
Manager.registerPass(std::make_unique<PrintProgramStats>(NeverPrint));
359+
Manager.registerPass(std::make_unique<PrintProgramStats>());
360360

361361
if (opts::PrintProfileStats)
362362
Manager.registerPass(std::make_unique<PrintProfileStats>(NeverPrint));

0 commit comments

Comments
 (0)