Skip to content

Commit 1927d21

Browse files
committed
LLVM and SPIRV-LLVM-Translator pulldown (WW24)
LLVM: llvm/llvm-project@dd6bcdb SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@24c5671
2 parents 737b519 + 828d2ab commit 1927d21

File tree

8,504 files changed

+383148
-123563
lines changed

Some content is hidden

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

8,504 files changed

+383148
-123563
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=cache+ -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=2 -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=cache+ -reorder-functions=hfsort+ -split-functions=3 \
67+
-reorder-blocks=ext-tsp -reorder-functions=hfsort+ -split-functions=3 \
6868
-split-all-cold -dyno-stats -icf=1 -use-gnu-stack
6969
```
7070
The output will look similar to the one below:

bolt/docs/doxygen.cfg.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "BOLT"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER =
41+
PROJECT_NUMBER = @PACKAGE_VERSION@
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ inline raw_ostream &operator<<(raw_ostream &OS, const SegmentInfo &SegInfo) {
8282
return OS;
8383
}
8484

85+
// AArch64-specific symbol markers used to delimit code/data in .text.
86+
enum class MarkerSymType : char {
87+
NONE = 0,
88+
CODE,
89+
DATA,
90+
};
91+
8592
enum class MemoryContentsType : char {
8693
UNKNOWN = 0, /// Unknown contents.
8794
POSSIBLE_JUMP_TABLE, /// Possibly a non-PIC jump table.
@@ -549,6 +556,9 @@ class BinaryContext {
549556

550557
std::unique_ptr<MCDisassembler> DisAsm;
551558

559+
/// Symbolic disassembler.
560+
std::unique_ptr<MCDisassembler> SymbolicDisAsm;
561+
552562
std::unique_ptr<MCAsmBackend> MAB;
553563

554564
/// Indicates if relocations are available for usage.
@@ -662,6 +672,11 @@ class BinaryContext {
662672
TheTriple->getArch() == llvm::Triple::x86_64;
663673
}
664674

675+
// AArch64-specific functions to check if symbol is used to delimit
676+
// code/data in .text. Code is marked by $x, data by $d.
677+
MarkerSymType getMarkerType(const SymbolRef &Symbol) const;
678+
bool isMarker(const SymbolRef &Symbol) const;
679+
665680
/// Iterate over all BinaryData.
666681
iterator_range<binary_data_const_iterator> getBinaryData() const {
667682
return make_range(BinaryDataMap.begin(), BinaryDataMap.end());
@@ -1187,18 +1202,20 @@ class BinaryContext {
11871202
uint64_t Offset = 0,
11881203
const BinaryFunction *Function = nullptr,
11891204
bool PrintMCInst = false, bool PrintMemData = false,
1190-
bool PrintRelocations = false) const;
1205+
bool PrintRelocations = false,
1206+
StringRef Endl = "\n") const;
11911207

11921208
/// Print a range of instructions.
11931209
template <typename Itr>
11941210
uint64_t
11951211
printInstructions(raw_ostream &OS, Itr Begin, Itr End, uint64_t Offset = 0,
11961212
const BinaryFunction *Function = nullptr,
11971213
bool PrintMCInst = false, bool PrintMemData = false,
1198-
bool PrintRelocations = false) const {
1214+
bool PrintRelocations = false,
1215+
StringRef Endl = "\n") const {
11991216
while (Begin != End) {
12001217
printInstruction(OS, *Begin, Offset, Function, PrintMCInst, PrintMemData,
1201-
PrintRelocations);
1218+
PrintRelocations, Endl);
12021219
Offset += computeCodeSize(Begin, Begin + 1);
12031220
++Begin;
12041221
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//==- bolt/Core/BinaryDomTree.h - Dominator Tree at low-level IR -*- C++ -*-==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file defines the BinaryDomTree class, which represents a dominator tree
10+
// in the CFG of a binary function.
11+
//
12+
//===----------------------------------------------------------------------===//
13+
14+
#ifndef BOLT_CORE_BINARY_DOMTREE_H
15+
#define BOLT_CORE_BINARY_DOMTREE_H
16+
17+
#include "llvm/Support/GenericDomTreeConstruction.h"
18+
19+
namespace llvm {
20+
namespace bolt {
21+
22+
class BinaryBasicBlock;
23+
using BinaryDomTreeNode = DomTreeNodeBase<BinaryBasicBlock>;
24+
using BinaryDominatorTree = DomTreeBase<BinaryBasicBlock>;
25+
26+
} // namespace bolt
27+
28+
// BinaryDominatorTree GraphTraits specializations.
29+
template <>
30+
struct GraphTraits<bolt::BinaryDomTreeNode *>
31+
: public DomTreeGraphTraitsBase<bolt::BinaryDomTreeNode,
32+
bolt::BinaryDomTreeNode::iterator> {};
33+
34+
template <>
35+
struct GraphTraits<const bolt::BinaryDomTreeNode *>
36+
: public DomTreeGraphTraitsBase<const bolt::BinaryDomTreeNode,
37+
bolt::BinaryDomTreeNode::const_iterator> {};
38+
39+
template <>
40+
struct GraphTraits<bolt::BinaryDominatorTree *>
41+
: public GraphTraits<bolt::BinaryDomTreeNode *> {
42+
static NodeRef getEntryNode(bolt::BinaryDominatorTree *DT) {
43+
return DT->getRootNode();
44+
}
45+
46+
static nodes_iterator nodes_begin(bolt::BinaryDominatorTree *N) {
47+
return df_begin(getEntryNode(N));
48+
}
49+
50+
static nodes_iterator nodes_end(bolt::BinaryDominatorTree *N) {
51+
return df_end(getEntryNode(N));
52+
}
53+
};
54+
55+
} // namespace llvm
56+
57+
#endif

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -667,9 +667,6 @@ class BinaryFunction {
667667
uint64_t Offset,
668668
uint64_t &TargetAddress);
669669

670-
DenseMap<const MCInst *, SmallVector<MCInst *, 4>>
671-
computeLocalUDChain(const MCInst *CurInstr);
672-
673670
BinaryFunction &operator=(const BinaryFunction &) = delete;
674671
BinaryFunction(const BinaryFunction &) = delete;
675672

@@ -836,6 +833,15 @@ class BinaryFunction {
836833
return make_range(JumpTables.begin(), JumpTables.end());
837834
}
838835

836+
/// Return relocation associated with a given \p Offset in the function,
837+
/// or nullptr if no such relocation exists.
838+
const Relocation *getRelocationAt(uint64_t Offset) const {
839+
assert(CurrentState == State::Empty &&
840+
"Relocations unavailable in the current function state.");
841+
auto RI = Relocations.find(Offset);
842+
return (RI == Relocations.end()) ? nullptr : &RI->second;
843+
}
844+
839845
/// Returns the raw binary encoding of this function.
840846
ErrorOr<ArrayRef<uint8_t>> getData() const;
841847

@@ -1951,11 +1957,6 @@ class BinaryFunction {
19511957
return ColdLSDASymbol;
19521958
}
19531959

1954-
/// True if the symbol is a mapping symbol used in AArch64 to delimit
1955-
/// data inside code section.
1956-
bool isDataMarker(const SymbolRef &Symbol, uint64_t SymbolSize) const;
1957-
bool isCodeMarker(const SymbolRef &Symbol, uint64_t SymbolSize) const;
1958-
19591960
void setOutputDataAddress(uint64_t Address) { OutputDataOffset = Address; }
19601961

19611962
uint64_t getOutputDataAddress() const { return OutputDataOffset; }

bolt/include/bolt/Core/BinaryLoop.h

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,13 @@
1515
#ifndef BOLT_CORE_BINARY_LOOP_H
1616
#define BOLT_CORE_BINARY_LOOP_H
1717

18-
#include "llvm/ADT/DepthFirstIterator.h"
1918
#include "llvm/Analysis/LoopInfoImpl.h"
20-
#include "llvm/Support/GenericDomTreeConstruction.h"
2119

2220
namespace llvm {
2321
namespace bolt {
2422

2523
class BinaryBasicBlock;
2624

27-
using BinaryDomTreeNode = DomTreeNodeBase<BinaryBasicBlock>;
28-
using BinaryDominatorTree = DomTreeBase<BinaryBasicBlock>;
29-
3025
class BinaryLoop : public LoopBase<BinaryBasicBlock, BinaryLoop> {
3126
public:
3227
BinaryLoop() : LoopBase<BinaryBasicBlock, BinaryLoop>() {}
@@ -62,35 +57,4 @@ class BinaryLoopInfo : public LoopInfoBase<BinaryBasicBlock, BinaryLoop> {
6257
} // namespace bolt
6358
} // namespace llvm
6459

65-
namespace llvm {
66-
67-
// BinaryDominatorTree GraphTraits specializations.
68-
template <>
69-
struct GraphTraits<bolt::BinaryDomTreeNode *>
70-
: public DomTreeGraphTraitsBase<bolt::BinaryDomTreeNode,
71-
bolt::BinaryDomTreeNode::iterator> {};
72-
73-
template <>
74-
struct GraphTraits<const bolt::BinaryDomTreeNode *>
75-
: public DomTreeGraphTraitsBase<const bolt::BinaryDomTreeNode,
76-
bolt::BinaryDomTreeNode::const_iterator> {};
77-
78-
template <>
79-
struct GraphTraits<bolt::BinaryDominatorTree *>
80-
: public GraphTraits<bolt::BinaryDomTreeNode *> {
81-
static NodeRef getEntryNode(bolt::BinaryDominatorTree *DT) {
82-
return DT->getRootNode();
83-
}
84-
85-
static nodes_iterator nodes_begin(bolt::BinaryDominatorTree *N) {
86-
return df_begin(getEntryNode(N));
87-
}
88-
89-
static nodes_iterator nodes_end(bolt::BinaryDominatorTree *N) {
90-
return df_end(getEntryNode(N));
91-
}
92-
};
93-
94-
} // namespace llvm
95-
9660
#endif

0 commit comments

Comments
 (0)