Skip to content

Commit f0706a9

Browse files
Merge branch 'main' into fix/172104-clang-cl-simd-intrinsics
2 parents 23714e1 + 9975cb1 commit f0706a9

File tree

225 files changed

+15471
-7128
lines changed

Some content is hidden

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

225 files changed

+15471
-7128
lines changed

.github/workflows/containers/github-action-ci-tooling/Dockerfile

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,7 @@ RUN apt-get update && \
109109
abi-dumper \
110110
autoconf \
111111
parallel \
112-
pkg-config && \
112+
pkg-config \
113+
universal-ctags && \
113114
apt-get clean && \
114115
rm -rf /var/lib/apt/lists/*
115-
116-
RUN git clone https://github.com/universal-ctags/ctags.git && \
117-
cd ctags && \
118-
./autogen.sh && \
119-
./configure && \
120-
sudo make install && \
121-
rm -Rf ../ctags
122-

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ namespace bolt {
6565

6666
class BinaryFunction;
6767

68+
using BinaryFunctionListType = std::vector<BinaryFunction *>;
69+
using ConstBinaryFunctionListType = std::vector<const BinaryFunction *>;
70+
6871
/// Information on loadable part of the file.
6972
struct SegmentInfo {
7073
uint64_t Address; /// Address of the segment in memory.
@@ -228,11 +231,11 @@ class BinaryContext {
228231
/// Store all functions in the binary, sorted by original address.
229232
std::map<uint64_t, BinaryFunction> BinaryFunctions;
230233

231-
/// A mutex that is used to control parallel accesses to BinaryFunctions
234+
/// A mutex that is used to control parallel accesses to BinaryFunctions.
232235
mutable llvm::sys::RWMutex BinaryFunctionsMutex;
233236

234-
/// Functions injected by BOLT
235-
std::vector<BinaryFunction *> InjectedBinaryFunctions;
237+
/// Functions injected by BOLT.
238+
BinaryFunctionListType InjectedBinaryFunctions;
236239

237240
/// Jump tables for all functions mapped by address.
238241
std::map<uint64_t, JumpTable *> JumpTables;
@@ -567,13 +570,13 @@ class BinaryContext {
567570
const InstructionListType &Instructions,
568571
const Twine &Name = "");
569572

570-
std::vector<BinaryFunction *> &getInjectedBinaryFunctions() {
573+
BinaryFunctionListType &getInjectedBinaryFunctions() {
571574
return InjectedBinaryFunctions;
572575
}
573576

574577
/// Return vector with all functions, i.e. include functions from the input
575578
/// binary and functions created by BOLT.
576-
std::vector<BinaryFunction *> getAllBinaryFunctions();
579+
BinaryFunctionListType getAllBinaryFunctions();
577580

578581
/// Construct a jump table for \p Function at \p Address or return an existing
579582
/// one at that location.
@@ -1385,7 +1388,7 @@ class BinaryContext {
13851388
const uint32_t SrcCUID, unsigned FileIndex);
13861389

13871390
/// Return functions in output layout order
1388-
std::vector<BinaryFunction *> getSortedFunctions();
1391+
BinaryFunctionListType getSortedFunctions();
13891392

13901393
/// Do the best effort to calculate the size of the function by emitting
13911394
/// its code, and relaxing branch instructions. By default, branch

bolt/include/bolt/Core/BinaryFunctionCallGraph.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef BOLT_PASSES_BINARY_FUNCTION_CALLGRAPH_H
1010
#define BOLT_PASSES_BINARY_FUNCTION_CALLGRAPH_H
1111

12+
#include "bolt/Core/BinaryContext.h"
1213
#include "bolt/Core/CallGraph.h"
1314
#include <deque>
1415
#include <functional>
@@ -18,7 +19,6 @@ namespace llvm {
1819
namespace bolt {
1920

2021
class BinaryFunction;
21-
class BinaryContext;
2222

2323
class BinaryFunctionCallGraph : public CallGraph {
2424
public:
@@ -46,7 +46,7 @@ class BinaryFunctionCallGraph : public CallGraph {
4646

4747
private:
4848
std::unordered_map<const BinaryFunction *, NodeId> FuncToNodeId;
49-
std::vector<BinaryFunction *> Funcs;
49+
BinaryFunctionListType Funcs;
5050
};
5151

5252
using CgFilterFunction = std::function<bool(const BinaryFunction &BF)>;

bolt/include/bolt/Passes/CacheMetrics.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,18 @@
1313
#ifndef BOLT_PASSES_CACHEMETRICS_H
1414
#define BOLT_PASSES_CACHEMETRICS_H
1515

16+
#include "bolt/Core/BinaryContext.h"
1617
#include <vector>
1718

1819
namespace llvm {
1920

2021
class raw_ostream;
2122

2223
namespace bolt {
23-
class BinaryFunction;
2424
namespace CacheMetrics {
2525

2626
/// Calculate and print various metrics related to instruction cache performance
27-
void printAll(raw_ostream &OS,
28-
const std::vector<BinaryFunction *> &BinaryFunctions);
27+
void printAll(raw_ostream &OS, const BinaryFunctionListType &BinaryFunctions);
2928

3029
} // namespace CacheMetrics
3130
} // namespace bolt

bolt/include/bolt/Passes/LongJmp.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,13 @@ class LongJmpPass : public BinaryFunctionPass {
8282
/// purposes, we need to do a size worst-case estimation. Real layout is done
8383
/// by RewriteInstance::mapFileSections()
8484
void tentativeLayout(const BinaryContext &BC,
85-
std::vector<BinaryFunction *> &SortedFunctions);
86-
uint64_t
87-
tentativeLayoutRelocMode(const BinaryContext &BC,
88-
std::vector<BinaryFunction *> &SortedFunctions,
89-
uint64_t DotAddress);
90-
uint64_t
91-
tentativeLayoutRelocColdPart(const BinaryContext &BC,
92-
std::vector<BinaryFunction *> &SortedFunctions,
93-
uint64_t DotAddress);
85+
BinaryFunctionListType &SortedFunctions);
86+
uint64_t tentativeLayoutRelocMode(const BinaryContext &BC,
87+
BinaryFunctionListType &SortedFunctions,
88+
uint64_t DotAddress);
89+
uint64_t tentativeLayoutRelocColdPart(const BinaryContext &BC,
90+
BinaryFunctionListType &SortedFunctions,
91+
uint64_t DotAddress);
9492
void tentativeBBLayout(const BinaryFunction &Func);
9593

9694
/// Update stubs addresses with their exact address after a round of stub

bolt/include/bolt/Profile/YAMLProfileReader.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class YAMLProfileReader : public ProfileReaderBase {
6868
}
6969

7070
/// Returns the binary functions with the parameter neighbor hash.
71-
std::optional<std::vector<BinaryFunction *>>
71+
std::optional<BinaryFunctionListType>
7272
getBFsWithNeighborHash(uint64_t NeighborHash) {
7373
auto It = NeighborHashToBFs.find(NeighborHash);
7474
return It == NeighborHashToBFs.end() ? std::nullopt
@@ -93,7 +93,7 @@ class YAMLProfileReader : public ProfileReaderBase {
9393
DenseMap<BinaryFunction *, std::set<BinaryFunction *>> BFAdjacencyMap;
9494

9595
/// Maps neighbor hashes to binary functions.
96-
DenseMap<uint64_t, std::vector<BinaryFunction *>> NeighborHashToBFs;
96+
DenseMap<uint64_t, BinaryFunctionListType> NeighborHashToBFs;
9797

9898
/// Adjacency map for profile functions in the call graph.
9999
DenseMap<yaml::bolt::BinaryFunctionProfile *,
@@ -187,7 +187,7 @@ class YAMLProfileReader : public ProfileReaderBase {
187187
StringSet<> ProfileFunctionNames;
188188

189189
/// BinaryFunction pointers indexed by YamlBP functions.
190-
std::vector<BinaryFunction *> ProfileBFs;
190+
BinaryFunctionListType ProfileBFs;
191191

192192
// Pseudo probe function GUID to inline tree node
193193
GUIDInlineTreeMap TopLevelGUIDToInlineTree;

bolt/lib/Core/BinaryContext.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ void BinaryContext::populateJumpTables() {
826826
}
827827

828828
void BinaryContext::skipMarkedFragments() {
829-
std::vector<BinaryFunction *> FragmentQueue;
829+
BinaryFunctionListType FragmentQueue;
830830
// Copy the functions to FragmentQueue.
831831
FragmentQueue.assign(FragmentsToSkip.begin(), FragmentsToSkip.end());
832832
auto addToWorklist = [&](BinaryFunction *Function) -> void {
@@ -1715,8 +1715,8 @@ unsigned BinaryContext::addDebugFilenameToUnit(const uint32_t DestCUID,
17151715
DestCUID, DstUnit->getVersion()));
17161716
}
17171717

1718-
std::vector<BinaryFunction *> BinaryContext::getSortedFunctions() {
1719-
std::vector<BinaryFunction *> SortedFunctions(BinaryFunctions.size());
1718+
BinaryFunctionListType BinaryContext::getSortedFunctions() {
1719+
BinaryFunctionListType SortedFunctions(BinaryFunctions.size());
17201720
llvm::transform(llvm::make_second_range(BinaryFunctions),
17211721
SortedFunctions.begin(),
17221722
[](BinaryFunction &BF) { return &BF; });
@@ -1725,8 +1725,8 @@ std::vector<BinaryFunction *> BinaryContext::getSortedFunctions() {
17251725
return SortedFunctions;
17261726
}
17271727

1728-
std::vector<BinaryFunction *> BinaryContext::getAllBinaryFunctions() {
1729-
std::vector<BinaryFunction *> AllFunctions;
1728+
BinaryFunctionListType BinaryContext::getAllBinaryFunctions() {
1729+
BinaryFunctionListType AllFunctions;
17301730
AllFunctions.reserve(BinaryFunctions.size() + InjectedBinaryFunctions.size());
17311731
llvm::transform(llvm::make_second_range(BinaryFunctions),
17321732
std::back_inserter(AllFunctions),

bolt/lib/Core/BinaryEmitter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ void BinaryEmitter::emitAll(StringRef OrgSecPrefix) {
232232
}
233233

234234
void BinaryEmitter::emitFunctions() {
235-
auto emit = [&](const std::vector<BinaryFunction *> &Functions) {
235+
auto emit = [&](const BinaryFunctionListType &Functions) {
236236
const bool HasProfile = BC.NumProfiledFuncs > 0;
237237
const bool OriginalAllowAutoPadding = Streamer.getAllowAutoPadding();
238238
for (BinaryFunction *Function : Functions) {
@@ -282,7 +282,7 @@ void BinaryEmitter::emitFunctions() {
282282
}
283283

284284
// Emit functions in sorted order.
285-
std::vector<BinaryFunction *> SortedFunctions = BC.getSortedFunctions();
285+
BinaryFunctionListType SortedFunctions = BC.getSortedFunctions();
286286
emit(SortedFunctions);
287287

288288
// Emit functions added by BOLT.

bolt/lib/Passes/BinaryPasses.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,7 +1609,7 @@ Error PrintProgramStats::runOnFunctions(BinaryContext &BC) {
16091609
}
16101610

16111611
if (!opts::PrintSortedBy.empty()) {
1612-
std::vector<BinaryFunction *> Functions;
1612+
BinaryFunctionListType Functions;
16131613
std::map<const BinaryFunction *, DynoStats> Stats;
16141614

16151615
for (auto &BFI : BC.getBinaryFunctions()) {
@@ -1700,7 +1700,7 @@ Error PrintProgramStats::runOnFunctions(BinaryContext &BC) {
17001700

17011701
// Collect and print information about suboptimal code layout on input.
17021702
if (opts::ReportBadLayout) {
1703-
std::vector<BinaryFunction *> SuboptimalFuncs;
1703+
BinaryFunctionListType SuboptimalFuncs;
17041704
for (auto &BFI : BC.getBinaryFunctions()) {
17051705
BinaryFunction &BF = BFI.second;
17061706
if (!BF.hasValidProfile())

bolt/lib/Passes/CacheMetrics.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ constexpr unsigned ITLBEntries = 16;
3030

3131
/// Initialize and return a position map for binary basic blocks
3232
void extractBasicBlockInfo(
33-
const std::vector<BinaryFunction *> &BinaryFunctions,
33+
const BinaryFunctionListType &BinaryFunctions,
3434
std::unordered_map<BinaryBasicBlock *, uint64_t> &BBAddr,
3535
std::unordered_map<BinaryBasicBlock *, uint64_t> &BBSize) {
3636

@@ -54,7 +54,7 @@ void extractBasicBlockInfo(
5454
/// the ordering of basic blocks. The method returns a pair
5555
/// (the number of fallthrough branches, the total number of branches)
5656
std::pair<uint64_t, uint64_t>
57-
calcTSPScore(const std::vector<BinaryFunction *> &BinaryFunctions,
57+
calcTSPScore(const BinaryFunctionListType &BinaryFunctions,
5858
const std::unordered_map<BinaryBasicBlock *, uint64_t> &BBAddr,
5959
const std::unordered_map<BinaryBasicBlock *, uint64_t> &BBSize) {
6060
uint64_t Score = 0;
@@ -95,7 +95,7 @@ using Predecessors = std::vector<std::pair<BinaryFunction *, uint64_t>>;
9595
/// Build a simplified version of the call graph: For every function, keep
9696
/// its callers and the frequencies of the calls
9797
std::unordered_map<const BinaryFunction *, Predecessors>
98-
extractFunctionCalls(const std::vector<BinaryFunction *> &BinaryFunctions) {
98+
extractFunctionCalls(const BinaryFunctionListType &BinaryFunctions) {
9999
std::unordered_map<const BinaryFunction *, Predecessors> Calls;
100100

101101
for (BinaryFunction *SrcFunction : BinaryFunctions) {
@@ -140,7 +140,7 @@ extractFunctionCalls(const std::vector<BinaryFunction *> &BinaryFunctions) {
140140
/// the page. The following procedure detects short and long calls, and
141141
/// estimates the expected number of cache misses for the long ones.
142142
double expectedCacheHitRatio(
143-
const std::vector<BinaryFunction *> &BinaryFunctions,
143+
const BinaryFunctionListType &BinaryFunctions,
144144
const std::unordered_map<BinaryBasicBlock *, uint64_t> &BBAddr,
145145
const std::unordered_map<BinaryBasicBlock *, uint64_t> &BBSize) {
146146
std::unordered_map<const BinaryFunction *, Predecessors> Calls =
@@ -213,7 +213,7 @@ double expectedCacheHitRatio(
213213
} // namespace
214214

215215
void CacheMetrics::printAll(raw_ostream &OS,
216-
const std::vector<BinaryFunction *> &BFs) {
216+
const BinaryFunctionListType &BFs) {
217217
// Stats related to hot-cold code splitting
218218
size_t NumFunctions = 0;
219219
size_t NumProfiledFunctions = 0;

0 commit comments

Comments
 (0)