Skip to content

Commit c763b52

Browse files
committed
Merge branch 'main' into guard-no-outer-loop-option
2 parents 5cc6df0 + 455b4fd commit c763b52

File tree

1,030 files changed

+36596
-14856
lines changed

Some content is hidden

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

1,030 files changed

+36596
-14856
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
# to receive an approval from a "code owner" in particular -- any LLVM project
88
# member can approve pull requests.
99
#
10-
# Note that GitHub's concept of "code owner" is independent from LLVM's own
11-
# "code owner" concept, they merely happen to share terminology. See
12-
# https://llvm.org/docs/DeveloperPolicy.html#code-owners, as well as the
13-
# CODE_OWNERS.txt files in the respective subproject directories.
10+
# This is independent of LLVM's own "maintainer" concept.
11+
# See https://llvm.org/docs/DeveloperPolicy.html#maintainers as well as the
12+
# Maintainers.* files in the the respective subproject directories.
1413

1514
/libcxx/ @llvm/reviewers-libcxx
1615
/libcxxabi/ @llvm/reviewers-libcxxabi

.github/workflows/docs.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,58 +112,87 @@ jobs:
112112
sudo apt-get update
113113
# swig and graphviz are lldb specific dependencies
114114
sudo apt-get install -y cmake ninja-build swig graphviz
115+
- name: Setup output folder
116+
run: mkdir built-docs
115117
- name: Build LLVM docs
116118
if: steps.docs-changed-subprojects.outputs.llvm_any_changed == 'true'
117119
run: |
118120
cmake -B llvm-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_SPHINX=ON ./llvm
119121
TZ=UTC ninja -C llvm-build docs-llvm-html docs-llvm-man
122+
mkdir built-docs/llvm
123+
cp -r llvm-build/docs/* built-docs/llvm/
120124
- name: Build Clang docs
121125
if: steps.docs-changed-subprojects.outputs.clang_any_changed == 'true'
122126
run: |
123127
cmake -B clang-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_SPHINX=ON ./llvm
124128
TZ=UTC ninja -C clang-build docs-clang-html docs-clang-man
129+
mkdir built-docs/clang
130+
cp -r clang-build/docs/* built-docs/clang/
125131
- name: Build clang-tools-extra docs
126132
if: steps.docs-changed-subprojects.outputs.clang-tools-extra_any_changed == 'true'
127133
run: |
128134
cmake -B clang-tools-extra-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" -DLLVM_ENABLE_SPHINX=ON ./llvm
129135
TZ=UTC ninja -C clang-tools-extra-build docs-clang-tools-html docs-clang-tools-man
136+
mkdir built-docs/clang-tools-extra
137+
cp -r clang-tools-extra-build/docs/* built-docs/clang-tools-extra/
130138
- name: Build LLDB docs
131139
if: steps.docs-changed-subprojects.outputs.lldb_any_changed == 'true'
132140
run: |
133141
cmake -B lldb-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;lldb" -DLLVM_ENABLE_SPHINX=ON ./llvm
134142
TZ=UTC ninja -C lldb-build docs-lldb-html docs-lldb-man
143+
mkdir built-docs/lldb
144+
cp -r lldb-build/docs/* built-docs/lldb/
135145
- name: Build libunwind docs
136146
if: steps.docs-changed-subprojects.outputs.libunwind_any_changed == 'true'
137147
run: |
138148
cmake -B libunwind-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES="libunwind" -DLLVM_ENABLE_SPHINX=ON ./runtimes
139149
TZ=UTC ninja -C libunwind-build docs-libunwind-html
150+
mkdir built-docs/libunwind
151+
cp -r libunwind-build/docs/* built-docs/libunwind
140152
- name: Build libcxx docs
141153
if: steps.docs-changed-subprojects.outputs.libcxx_any_changed == 'true'
142154
run: |
143155
cmake -B libcxx-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES="libcxxabi;libcxx;libunwind" -DLLVM_ENABLE_SPHINX=ON ./runtimes
144156
TZ=UTC ninja -C libcxx-build docs-libcxx-html
157+
mkdir built-docs/libcxx
158+
cp -r libcxx-build/docs/* built-docs/libcxx/
145159
- name: Build libc docs
146160
if: steps.docs-changed-subprojects.outputs.libc_any_changed == 'true'
147161
run: |
148162
cmake -B libc-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES="libc" -DLLVM_ENABLE_SPHINX=ON ./runtimes
149163
TZ=UTC ninja -C libc-build docs-libc-html
164+
mkdir built-docs/libc
165+
cp -r libc-build/libc/docs/* built-docs/libc/
150166
- name: Build LLD docs
151167
if: steps.docs-changed-subprojects.outputs.lld_any_changed == 'true'
152168
run: |
153169
cmake -B lld-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="lld" -DLLVM_ENABLE_SPHINX=ON ./llvm
154170
TZ=UTC ninja -C lld-build docs-lld-html
171+
mkdir built-docs/lld
172+
cp -r lld-build/docs/* built-docs/lld/
155173
- name: Build OpenMP docs
156174
if: steps.docs-changed-subprojects.outputs.openmp_any_changed == 'true'
157175
run: |
158176
cmake -B openmp-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;openmp" -DLLVM_ENABLE_SPHINX=ON ./llvm
159177
TZ=UTC ninja -C openmp-build docs-openmp-html
178+
mkdir built-docs/openmp
179+
cp -r openmp-build/docs/* built-docs/openmp/
160180
- name: Build Polly docs
161181
if: steps.docs-changed-subprojects.outputs.polly_any_changed == 'true'
162182
run: |
163183
cmake -B polly-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="polly" -DLLVM_ENABLE_SPHINX=ON ./llvm
164184
TZ=UTC ninja -C polly-build docs-polly-html docs-polly-man
185+
mkdir built-docs/polly
186+
cp -r polly-build/docs/* built-docs/polly/
165187
- name: Build Flang docs
166188
if: steps.docs-changed-subprojects.outputs.flang_any_changed == 'true'
167189
run: |
168190
cmake -B flang-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;mlir;flang" -DLLVM_ENABLE_SPHINX=ON ./llvm
169191
TZ=UTC ninja -C flang-build docs-flang-html
192+
mkdir built-docs/flang
193+
cp -r flang-build/docs/* built-docs/flang/
194+
- name: Upload docs
195+
uses: actions/upload-artifact@v4
196+
with:
197+
name: docs-output
198+
path: built-docs/
File renamed without changes.

bolt/include/bolt/Profile/DataAggregator.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ class DataAggregator : public DataReader {
170170
std::string BuildIDBinaryName;
171171

172172
/// Memory map info for a single file as recorded in perf.data
173+
/// When a binary has multiple text segments, the Size is computed as the
174+
/// difference of the last address of these segments from the BaseAddress.
175+
/// The base addresses of all text segments must be the same.
173176
struct MMapInfo {
174177
uint64_t BaseAddress{0}; /// Base address of the mapped binary.
175178
uint64_t MMapAddress{0}; /// Address of the executable segment.
@@ -493,6 +496,11 @@ class DataAggregator : public DataReader {
493496
/// and return a file name matching a given \p FileBuildID.
494497
std::optional<StringRef> getFileNameForBuildID(StringRef FileBuildID);
495498

499+
/// Get a constant reference to the parsed binary mmap entries.
500+
const std::unordered_map<uint64_t, MMapInfo> &getBinaryMMapInfo() {
501+
return BinaryMMapInfo;
502+
}
503+
496504
friend class YAMLProfileWriter;
497505
};
498506
} // namespace bolt

bolt/lib/Passes/VeneerElimination.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,17 @@ Error VeneerElimination::runOnFunctions(BinaryContext &BC) {
4646
if (BF.isIgnored())
4747
continue;
4848

49+
MCInst &FirstInstruction = *(BF.begin()->begin());
4950
const MCSymbol *VeneerTargetSymbol = 0;
5051
uint64_t TargetAddress;
51-
if (BC.MIB->matchAbsLongVeneer(BF, TargetAddress)) {
52+
if (BC.MIB->isTailCall(FirstInstruction)) {
53+
VeneerTargetSymbol = BC.MIB->getTargetSymbol(FirstInstruction);
54+
} else if (BC.MIB->matchAbsLongVeneer(BF, TargetAddress)) {
5255
if (BinaryFunction *TargetBF =
5356
BC.getBinaryFunctionAtAddress(TargetAddress))
5457
VeneerTargetSymbol = TargetBF->getSymbol();
55-
} else {
56-
MCInst &FirstInstruction = *(BF.begin()->begin());
57-
if (BC.MIB->hasAnnotation(FirstInstruction, "AArch64Veneer"))
58-
VeneerTargetSymbol = BC.MIB->getTargetSymbol(FirstInstruction, 1);
58+
} else if (BC.MIB->hasAnnotation(FirstInstruction, "AArch64Veneer")) {
59+
VeneerTargetSymbol = BC.MIB->getTargetSymbol(FirstInstruction, 1);
5960
}
6061

6162
if (!VeneerTargetSymbol)

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ cl::opt<bool> ReadPreAggregated(
9595
"pa", cl::desc("skip perf and read data from a pre-aggregated file format"),
9696
cl::cat(AggregatorCategory));
9797

98+
cl::opt<std::string>
99+
ReadPerfEvents("perf-script-events",
100+
cl::desc("skip perf event collection by supplying a "
101+
"perf-script output in a textual format"),
102+
cl::ReallyHidden, cl::init(""), cl::cat(AggregatorCategory));
103+
98104
static cl::opt<bool>
99105
TimeAggregator("time-aggr",
100106
cl::desc("time BOLT aggregator"),
@@ -167,8 +173,9 @@ void DataAggregator::findPerfExecutable() {
167173
void DataAggregator::start() {
168174
outs() << "PERF2BOLT: Starting data aggregation job for " << Filename << "\n";
169175

170-
// Don't launch perf for pre-aggregated files
171-
if (opts::ReadPreAggregated)
176+
// Don't launch perf for pre-aggregated files or when perf input is specified
177+
// by the user.
178+
if (opts::ReadPreAggregated || !opts::ReadPerfEvents.empty())
172179
return;
173180

174181
findPerfExecutable();
@@ -464,6 +471,13 @@ void DataAggregator::filterBinaryMMapInfo() {
464471

465472
int DataAggregator::prepareToParse(StringRef Name, PerfProcessInfo &Process,
466473
PerfProcessErrorCallbackTy Callback) {
474+
if (!opts::ReadPerfEvents.empty()) {
475+
outs() << "PERF2BOLT: using pre-processed perf events for '" << Name
476+
<< "' (perf-script-events)\n";
477+
ParsingBuf = opts::ReadPerfEvents;
478+
return 0;
479+
}
480+
467481
std::string Error;
468482
outs() << "PERF2BOLT: waiting for perf " << Name
469483
<< " collection to finish...\n";
@@ -2056,15 +2070,6 @@ std::error_code DataAggregator::parseMMapEvents() {
20562070
if (FileMMapInfo.first == "(deleted)")
20572071
continue;
20582072

2059-
// Consider only the first mapping of the file for any given PID
2060-
auto Range = GlobalMMapInfo.equal_range(FileMMapInfo.first);
2061-
bool PIDExists = llvm::any_of(make_range(Range), [&](const auto &MI) {
2062-
return MI.second.PID == FileMMapInfo.second.PID;
2063-
});
2064-
2065-
if (PIDExists)
2066-
continue;
2067-
20682073
GlobalMMapInfo.insert(FileMMapInfo);
20692074
}
20702075

@@ -2116,12 +2121,22 @@ std::error_code DataAggregator::parseMMapEvents() {
21162121
<< " using file offset 0x" << Twine::utohexstr(MMapInfo.Offset)
21172122
<< ". Ignoring profile data for this mapping\n";
21182123
continue;
2119-
} else {
2120-
MMapInfo.BaseAddress = *BaseAddress;
21212124
}
2125+
MMapInfo.BaseAddress = *BaseAddress;
21222126
}
21232127

2124-
BinaryMMapInfo.insert(std::make_pair(MMapInfo.PID, MMapInfo));
2128+
// Try to add MMapInfo to the map and update its size. Large binaries may
2129+
// span to multiple text segments, so the mapping is inserted only on the
2130+
// first occurrence.
2131+
if (!BinaryMMapInfo.insert(std::make_pair(MMapInfo.PID, MMapInfo)).second)
2132+
assert(MMapInfo.BaseAddress == BinaryMMapInfo[MMapInfo.PID].BaseAddress &&
2133+
"Base address on multiple segment mappings should match");
2134+
2135+
// Update mapping size.
2136+
const uint64_t EndAddress = MMapInfo.MMapAddress + MMapInfo.Size;
2137+
const uint64_t Size = EndAddress - BinaryMMapInfo[MMapInfo.PID].BaseAddress;
2138+
if (Size > BinaryMMapInfo[MMapInfo.PID].Size)
2139+
BinaryMMapInfo[MMapInfo.PID].Size = Size;
21252140
}
21262141

21272142
if (BinaryMMapInfo.empty()) {

bolt/test/AArch64/veneer-lld-abs.s

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
## Check that llvm-bolt correctly recognizes long absolute thunks generated
2-
## by LLD.
1+
## Check that llvm-bolt correctly recognizes veneers/thunks for absolute code
2+
## generated by LLD.
33

44
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
55
# RUN: %clang %cflags -fno-PIC -no-pie %t.o -o %t.exe -nostdlib \
@@ -12,40 +12,63 @@
1212

1313
.text
1414
.balign 4
15-
.global foo
16-
.type foo, %function
17-
foo:
18-
adrp x1, foo
15+
.global far_function
16+
.type far_function, %function
17+
far_function:
1918
ret
20-
.size foo, .-foo
19+
.size far_function, .-far_function
20+
21+
.global near_function
22+
.type near_function, %function
23+
near_function:
24+
ret
25+
.size near_function, .-near_function
26+
27+
## Force relocations against .text.
28+
.reloc 0, R_AARCH64_NONE
2129

2230
.section ".mytext", "ax"
2331
.balign 4
2432

25-
.global __AArch64AbsLongThunk_foo
26-
.type __AArch64AbsLongThunk_foo, %function
27-
__AArch64AbsLongThunk_foo:
33+
## This version of a thunk is always generated by LLD for function calls
34+
## spanning more than 256MB.
35+
.global __AArch64AbsLongThunk_far_function
36+
.type __AArch64AbsLongThunk_far_function, %function
37+
__AArch64AbsLongThunk_far_function:
2838
ldr x16, .L1
2939
br x16
30-
# CHECK-INPUT-LABEL: <__AArch64AbsLongThunk_foo>:
40+
# CHECK-INPUT-LABEL: <__AArch64AbsLongThunk_far_function>:
3141
# CHECK-INPUT-NEXT: ldr
3242
# CHECK-INPUT-NEXT: br
3343
.L1:
34-
.quad foo
35-
.size __AArch64AbsLongThunk_foo, .-__AArch64AbsLongThunk_foo
44+
.quad far_function
45+
.size __AArch64AbsLongThunk_far_function, .-__AArch64AbsLongThunk_far_function
46+
47+
## If a callee is closer than 256MB away, LLD may generate a thunk with a direct
48+
## jump to the callee. Note, that the name might still include "AbsLong".
49+
.global __AArch64AbsLongThunk_near_function
50+
.type __AArch64AbsLongThunk_near_function, %function
51+
__AArch64AbsLongThunk_near_function:
52+
b near_function
53+
# CHECK-INPUT-LABEL: <__AArch64AbsLongThunk_near_function>:
54+
# CHECK-INPUT-NEXT: b {{.*}} <near_function>
55+
.size __AArch64AbsLongThunk_near_function, .-__AArch64AbsLongThunk_near_function
3656

37-
## Check that the thunk was removed from .text and _start() calls foo()
57+
## Check that thunks were removed from .text, and _start calls functions
3858
## directly.
3959

40-
# CHECK-OUTPUT-NOT: __AArch64AbsLongThunk_foo
60+
# CHECK-OUTPUT-NOT: __AArch64AbsLongThunk_{{.*}}
4161

4262
.global _start
4363
.type _start, %function
4464
_start:
4565
# CHECK-INPUT-LABEL: <_start>:
4666
# CHECK-OUTPUT-LABEL: <_start>:
47-
bl __AArch64AbsLongThunk_foo
48-
# CHECK-INPUT-NEXT: bl {{.*}} <__AArch64AbsLongThunk_foo>
49-
# CHECK-OUTPUT-NEXT: bl {{.*}} <foo>
67+
bl __AArch64AbsLongThunk_far_function
68+
bl __AArch64AbsLongThunk_near_function
69+
# CHECK-INPUT-NEXT: bl {{.*}} <__AArch64AbsLongThunk_far_function>
70+
# CHECK-INPUT-NEXT: bl {{.*}} <__AArch64AbsLongThunk_near_function>
71+
# CHECK-OUTPUT-NEXT: bl {{.*}} <far_function>
72+
# CHECK-OUTPUT-NEXT: bl {{.*}} <near_function>
5073
ret
5174
.size _start, .-_start

bolt/unittests/Core/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ set(LLVM_LINK_COMPONENTS
88
add_bolt_unittest(CoreTests
99
BinaryContext.cpp
1010
MCPlusBuilder.cpp
11+
MemoryMaps.cpp
1112
DynoStats.cpp
1213

1314
DISABLE_LLVM_LINK_LLVM_DYLIB
@@ -17,6 +18,8 @@ target_link_libraries(CoreTests
1718
PRIVATE
1819
LLVMBOLTCore
1920
LLVMBOLTRewrite
21+
LLVMBOLTProfile
22+
LLVMTestingSupport
2023
)
2124

2225
foreach (tgt ${BOLT_TARGETS_TO_BUILD})

0 commit comments

Comments
 (0)