Skip to content

Commit d7d0880

Browse files
committed
LLVM and SPIRV-LLVM-Translator pulldown (WW29)
LLVM: llvm/llvm-project@132d711 SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@18d1f41
2 parents 1ac30ae + dcaa649 commit d7d0880

File tree

6,355 files changed

+386397
-714496
lines changed

Some content is hidden

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

6,355 files changed

+386397
-714496
lines changed

bolt/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ Once you have `perf.fdata` ready, you can use it for optimizations with
180180
BOLT. Assuming your environment is setup to include the right path, execute
181181
`llvm-bolt`:
182182
```
183-
$ llvm-bolt <executable> -o <executable>.bolt -data=perf.fdata -reorder-blocks=ext-tsp -reorder-functions=hfsort -split-functions=2 -split-all-cold -split-eh -dyno-stats
183+
$ llvm-bolt <executable> -o <executable>.bolt -data=perf.fdata -reorder-blocks=ext-tsp -reorder-functions=hfsort -split-functions -split-all-cold -split-eh -dyno-stats
184184
```
185185

186186
If you do need an updated debug info, then add `-update-debug-sections` option

bolt/docs/OptimizingClang.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Notice that we are passing `clang-7` to `perf2bolt` which is the real binary tha
6464
the generated profile:
6565
```bash
6666
$ llvm-bolt $CPATH/clang-7 -o $CPATH/clang-7.bolt -b clang-7.yaml \
67-
-reorder-blocks=ext-tsp -reorder-functions=hfsort+ -split-functions=3 \
67+
-reorder-blocks=ext-tsp -reorder-functions=hfsort+ -split-functions \
6868
-split-all-cold -dyno-stats -icf=1 -use-gnu-stack
6969
```
7070
The output will look similar to the one below:

bolt/include/bolt/Core/BinaryBasicBlock.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -634,14 +634,12 @@ class BinaryBasicBlock {
634634

635635
/// Test if BB is a predecessor of this block.
636636
bool isPredecessor(const BinaryBasicBlock *BB) const {
637-
auto Itr = std::find(Predecessors.begin(), Predecessors.end(), BB);
638-
return Itr != Predecessors.end();
637+
return llvm::is_contained(Predecessors, BB);
639638
}
640639

641640
/// Test if BB is a successor of this block.
642641
bool isSuccessor(const BinaryBasicBlock *BB) const {
643-
auto Itr = std::find(Successors.begin(), Successors.end(), BB);
644-
return Itr != Successors.end();
642+
return llvm::is_contained(Successors, BB);
645643
}
646644

647645
/// Test if this BB has a valid execution count.

bolt/include/bolt/Core/BinaryData.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class BinaryData {
112112
bool nameStartsWith(StringRef Prefix) const;
113113

114114
bool hasSymbol(const MCSymbol *Symbol) const {
115-
return std::find(Symbols.begin(), Symbols.end(), Symbol) != Symbols.end();
115+
return llvm::is_contained(Symbols, Symbol);
116116
}
117117

118118
bool isAbsolute() const;

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -716,9 +716,8 @@ class BinaryFunction {
716716
BB->setOffset(Offset);
717717

718718
BasicBlockOffsets.emplace_back(Offset, BB);
719-
assert(std::is_sorted(BasicBlockOffsets.begin(), BasicBlockOffsets.end(),
720-
CompareBasicBlockOffsets()) &&
721-
std::is_sorted(begin(), end()));
719+
assert(llvm::is_sorted(BasicBlockOffsets, CompareBasicBlockOffsets()) &&
720+
llvm::is_sorted(blocks()));
722721

723722
return BB;
724723
}
@@ -888,8 +887,9 @@ class BinaryFunction {
888887

889888
/// Update layout of basic blocks used for output.
890889
void updateBasicBlockLayout(BasicBlockOrderType &NewLayout) {
891-
BasicBlocksPreviousLayout = BasicBlocksLayout;
890+
assert(NewLayout.size() == BasicBlocks.size() && "Layout size mismatch.");
892891

892+
BasicBlocksPreviousLayout = BasicBlocksLayout;
893893
if (NewLayout != BasicBlocksLayout) {
894894
ModifiedLayout = true;
895895
BasicBlocksLayout.clear();

bolt/include/bolt/Core/DynoStats.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ DynoStats getDynoStats(const BinaryFunction &BF);
146146

147147
/// Return program-wide dynostats.
148148
template <typename FuncsType>
149-
inline DynoStats getDynoStats(const FuncsType &Funcs) {
150-
bool IsAArch64 = Funcs.begin()->second.getBinaryContext().isAArch64();
149+
inline DynoStats getDynoStats(const FuncsType &Funcs, bool IsAArch64) {
151150
DynoStats dynoStats(IsAArch64);
152151
for (auto &BFI : Funcs) {
153152
auto &BF = BFI.second;
@@ -160,16 +159,16 @@ inline DynoStats getDynoStats(const FuncsType &Funcs) {
160159
/// Call a function with optional before and after dynostats printing.
161160
template <typename FnType, typename FuncsType>
162161
inline void callWithDynoStats(FnType &&Func, const FuncsType &Funcs,
163-
StringRef Phase, const bool Flag) {
164-
bool IsAArch64 = Funcs.begin()->second.getBinaryContext().isAArch64();
162+
StringRef Phase, const bool Flag,
163+
bool IsAArch64) {
165164
DynoStats DynoStatsBefore(IsAArch64);
166165
if (Flag)
167-
DynoStatsBefore = getDynoStats(Funcs);
166+
DynoStatsBefore = getDynoStats(Funcs, IsAArch64);
168167

169168
Func();
170169

171170
if (Flag) {
172-
const DynoStats DynoStatsAfter = getDynoStats(Funcs);
171+
const DynoStats DynoStatsAfter = getDynoStats(Funcs, IsAArch64);
173172
const bool Changed = (DynoStatsAfter != DynoStatsBefore);
174173
outs() << "BOLT-INFO: program-wide dynostats after running " << Phase
175174
<< (Changed ? "" : " (no change)") << ":\n\n"

bolt/include/bolt/Passes/BinaryPasses.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ class DynoStatsPrintPass : public BinaryFunctionPass {
7171
bool shouldPrint(const BinaryFunction &BF) const override { return false; }
7272

7373
void runOnFunctions(BinaryContext &BC) override {
74-
const DynoStats NewDynoStats = getDynoStats(BC.getBinaryFunctions());
74+
const DynoStats NewDynoStats =
75+
getDynoStats(BC.getBinaryFunctions(), BC.isAArch64());
7576
const bool Changed = (NewDynoStats != PrevDynoStats);
7677
outs() << "BOLT-INFO: program-wide dynostats " << Title
7778
<< (Changed ? "" : " (no change)") << ":\n\n"

bolt/include/bolt/Passes/SplitFunctions.h

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,29 @@ namespace bolt {
1818

1919
/// Split function code in multiple parts.
2020
class SplitFunctions : public BinaryFunctionPass {
21-
public:
22-
/// Settings for splitting function bodies into hot/cold partitions.
23-
enum SplittingType : char {
24-
ST_NONE = 0, /// Do not split functions.
25-
ST_LARGE, /// In non-relocation mode, only split functions that
26-
/// are too large to fit into the original space.
27-
ST_ALL, /// Split all functions.
28-
};
29-
3021
private:
3122
/// Split function body into fragments.
32-
void splitFunction(BinaryFunction &Function);
23+
template <typename SplitStrategy>
24+
void splitFunction(BinaryFunction &Function, SplitStrategy Strategy = {});
25+
26+
/// Map basic block labels to their trampoline block labels.
27+
using TrampolineSetType = DenseMap<const MCSymbol *, const MCSymbol *>;
28+
29+
using BasicBlockOrderType = BinaryFunction::BasicBlockOrderType;
3330

3431
/// Create trampoline landing pads for exception handling code to guarantee
3532
/// that every landing pad is placed in the same function fragment as the
3633
/// corresponding thrower block. The trampoline landing pad, when created,
3734
/// will redirect the execution to the real landing pad in a different
3835
/// fragment.
39-
void createEHTrampolines(BinaryFunction &Function) const;
36+
TrampolineSetType createEHTrampolines(BinaryFunction &Function) const;
37+
38+
/// Merge trampolines into \p Layout without trampolines. The merge will place
39+
/// a trampoline immediately before its destination. Used to revert the effect
40+
/// of trampolines after createEHTrampolines().
41+
BasicBlockOrderType
42+
mergeEHTrampolines(BinaryFunction &BF, BasicBlockOrderType &Layout,
43+
const TrampolineSetType &Trampolines) const;
4044

4145
std::atomic<uint64_t> SplitBytesHot{0ull};
4246
std::atomic<uint64_t> SplitBytesCold{0ull};

bolt/include/bolt/Rewrite/DWARFRewriter.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ class DWARFRewriter {
3838

3939
/// Stores and serializes information that will be put into the
4040
/// .debug_ranges DWARF section.
41-
std::unique_ptr<DebugRangesSectionWriter> RangesSectionWriter;
41+
std::unique_ptr<DebugRangesSectionWriter> LegacyRangesSectionWriter;
42+
43+
/// Stores and serializes information that will be put into the
44+
/// .debug_rnglists DWARF section.
45+
std::unique_ptr<DebugRangeListsSectionWriter> RangeListsSectionWriter;
4246

4347
/// Stores and serializes information that will be put into the
4448
/// .debug_aranges DWARF section.

bolt/lib/Core/BinaryBasicBlock.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ BinaryBasicBlock::getBranchStats(const BinaryBasicBlock *Succ) const {
544544
}
545545

546546
if (TotalCount > 0) {
547-
auto Itr = std::find(Successors.begin(), Successors.end(), Succ);
547+
auto Itr = llvm::find(Successors, Succ);
548548
assert(Itr != Successors.end());
549549
const BinaryBranchInfo &BI = BranchInfo[Itr - Successors.begin()];
550550
if (BI.Count && BI.Count != COUNT_NO_PROFILE) {

0 commit comments

Comments
 (0)