Skip to content

Commit 18a48ef

Browse files
committed
Merge remote-tracking branch 'yi/main' into ecl_arg_kind_fix
2 parents 5ac4b76 + 2856db0 commit 18a48ef

File tree

2,820 files changed

+94181
-34818
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,820 files changed

+94181
-34818
lines changed

.github/new-prs-labeler.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ clang-tidy:
308308
- clang-tools-extra/docs/clang-tidy/**
309309
- clang-tools-extra/test/clang-tidy/**
310310

311+
clang-tools-extra:
312+
- clang-tools-extra/**
313+
311314
tools:llvm-mca:
312315
- llvm/tools/llvm-mca/**
313316
- llvm/include/llvm/MCA/**
@@ -591,13 +594,16 @@ mlgo:
591594
- llvm/include/llvm/Analysis/*Runner.h
592595
- llvm/unittests/Analysis/ML*
593596
- llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
597+
- llvm/lib/Analysis/TrainingLogger.cpp
594598
- llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
599+
- llvm/include/llvm/Analysis/Utils/TrainingLogger.h
595600
- llvm/test/Analysis/FunctionPropertiesAnalysis/*
596601
- llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp
597602
- llvm/test/Transforms/inline/ML/**
598603
- llvm/lib/CodeGen/ML*
599604
- llvm/unittests/CodeGen/ML*
600605
- llvm/test/CodeGen/MLRegAlloc/**
606+
- llvm/utils/mlgo-utils/*
601607

602608
tools:llvm-exegesis:
603609
- llvm/tools/llvm-exegesis/**

.github/workflows/issue-subscriber.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ jobs:
2222
- name: Setup Automation Script
2323
working-directory: ./llvm/utils/git/
2424
run: |
25-
chmod a+x github-automation.py
2625
pip install -r requirements.txt
2726
2827
- name: Update watchers
@@ -31,7 +30,7 @@ jobs:
3130
env:
3231
LABEL_NAME: ${{ github.event.label.name }}
3332
run: |
34-
./github-automation.py \
33+
python3 ./github-automation.py \
3534
--token '${{ secrets.ISSUE_SUBSCRIBER_TOKEN }}' \
3635
issue-subscriber \
3736
--issue-number '${{ github.event.issue.number }}' \

.github/workflows/new-prs.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,12 @@ jobs:
4343
- name: Setup Automation Script
4444
working-directory: ./llvm/utils/git/
4545
run: |
46-
chmod a+x github-automation.py
4746
pip install -r requirements.txt
4847
4948
- name: Greet Author
5049
working-directory: ./llvm/utils/git/
5150
run: |
52-
./github-automation.py \
51+
python3 ./github-automation.py \
5352
--token '${{ secrets.GITHUB_TOKEN }}' \
5453
pr-greeter \
5554
--issue-number "${{ github.event.pull_request.number }}"

.github/workflows/pr-subscriber.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@ jobs:
2222
- name: Setup Automation Script
2323
working-directory: ./llvm/utils/git/
2424
run: |
25-
chmod a+x github-automation.py
2625
pip install -r requirements.txt
2726
2827
- name: Update watchers
2928
working-directory: ./llvm/utils/git/
3029
run: |
31-
./github-automation.py \
30+
python3 ./github-automation.py \
3231
--token '${{ secrets.ISSUE_SUBSCRIBER_TOKEN }}' \
3332
pr-subscriber \
3433
--issue-number "${{ github.event.number }}" \

bolt/docs/BAT.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,15 @@ Header:
6969

7070
The header is followed by Functions table with `NumFuncs` entries.
7171
Output binary addresses are delta encoded, meaning that only the difference with
72-
the previous output address is stored. Addresses implicitly start at zero.
72+
the last previous output address is stored. Addresses implicitly start at zero.
73+
Output addresses are continuous through function start addresses and function
74+
internal offsets, and between hot and cold fragments, to better spread deltas
75+
and save space.
76+
7377
Hot indices are delta encoded, implicitly starting at zero.
7478
| Entry | Encoding | Description |
7579
| ------ | ------| ----------- |
76-
| `Address` | Delta, ULEB128 | Function address in the output binary |
80+
| `Address` | Continuous, Delta, ULEB128 | Function address in the output binary |
7781
| `HotIndex` | Delta, ULEB128 | Cold functions only: index of corresponding hot function in hot functions table |
7882
| `NumEntries` | ULEB128 | Number of address translation entries for a function |
7983

@@ -82,10 +86,10 @@ function.
8286

8387
### Address translation table
8488
Delta encoding means that only the difference with the previous corresponding
85-
entry is encoded. Offsets implicitly start at zero.
89+
entry is encoded. Input offsets implicitly start at zero.
8690
| Entry | Encoding | Description |
8791
| ------ | ------| ----------- |
88-
| `OutputOffset` | Delta, ULEB128 | Function offset in output binary |
92+
| `OutputOffset` | Continuous, Delta, ULEB128 | Function offset in output binary |
8993
| `InputOffset` | Delta, SLEB128 | Function offset in input binary with `BRANCHENTRY` LSB bit |
9094

9195
`BRANCHENTRY` bit denotes whether a given offset pair is a control flow source

bolt/include/bolt/Profile/BoltAddressTranslation.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,14 @@ class BoltAddressTranslation {
121121

122122
/// Write the serialized address translation table for a function.
123123
template <bool Cold>
124-
void writeMaps(std::map<uint64_t, MapTy> &Maps, raw_ostream &OS);
124+
void writeMaps(std::map<uint64_t, MapTy> &Maps, uint64_t &PrevAddress,
125+
raw_ostream &OS);
125126

126127
/// Read the serialized address translation table for a function.
127128
/// Return a parse error if failed.
128129
template <bool Cold>
129-
void parseMaps(std::vector<uint64_t> &HotFuncs, DataExtractor &DE,
130-
uint64_t &Offset, Error &Err);
130+
void parseMaps(std::vector<uint64_t> &HotFuncs, uint64_t &PrevAddress,
131+
DataExtractor &DE, uint64_t &Offset, Error &Err);
131132

132133
std::map<uint64_t, MapTy> Maps;
133134

bolt/lib/Profile/BoltAddressTranslation.cpp

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,17 @@ void BoltAddressTranslation::write(const BinaryContext &BC, raw_ostream &OS) {
102102
}
103103
}
104104

105-
writeMaps</*Cold=*/false>(Maps, OS);
106-
writeMaps</*Cold=*/true>(Maps, OS);
105+
// Output addresses are delta-encoded
106+
uint64_t PrevAddress = 0;
107+
writeMaps</*Cold=*/false>(Maps, PrevAddress, OS);
108+
writeMaps</*Cold=*/true>(Maps, PrevAddress, OS);
107109

108110
outs() << "BOLT-INFO: Wrote " << Maps.size() << " BAT maps\n";
109111
}
110112

111113
template <bool Cold>
112114
void BoltAddressTranslation::writeMaps(std::map<uint64_t, MapTy> &Maps,
113-
raw_ostream &OS) {
115+
uint64_t &PrevAddress, raw_ostream &OS) {
114116
const uint32_t NumFuncs =
115117
llvm::count_if(llvm::make_first_range(Maps), [&](const uint64_t Address) {
116118
return Cold == ColdPartSource.count(Address);
@@ -119,8 +121,6 @@ void BoltAddressTranslation::writeMaps(std::map<uint64_t, MapTy> &Maps,
119121
LLVM_DEBUG(dbgs() << "Writing " << NumFuncs << (Cold ? " cold" : "")
120122
<< " functions for BAT.\n");
121123
size_t PrevIndex = 0;
122-
// Output addresses are delta-encoded
123-
uint64_t PrevAddress = 0;
124124
for (auto &MapEntry : Maps) {
125125
const uint64_t Address = MapEntry.first;
126126
// Only process cold fragments in cold mode, and vice versa.
@@ -139,12 +139,14 @@ void BoltAddressTranslation::writeMaps(std::map<uint64_t, MapTy> &Maps,
139139
PrevIndex = HotIndex;
140140
}
141141
encodeULEB128(NumEntries, OS);
142-
uint64_t InOffset = 0, OutOffset = 0;
142+
uint64_t InOffset = 0;
143143
// Output and Input addresses and delta-encoded
144144
for (std::pair<const uint32_t, uint32_t> &KeyVal : Map) {
145-
encodeULEB128(KeyVal.first - OutOffset, OS);
145+
const uint64_t OutputAddress = KeyVal.first + Address;
146+
encodeULEB128(OutputAddress - PrevAddress, OS);
147+
PrevAddress = OutputAddress;
146148
encodeSLEB128(KeyVal.second - InOffset, OS);
147-
std::tie(OutOffset, InOffset) = KeyVal;
149+
InOffset = KeyVal.second;
148150
}
149151
}
150152
}
@@ -170,21 +172,21 @@ std::error_code BoltAddressTranslation::parse(StringRef Buf) {
170172

171173
Error Err(Error::success());
172174
std::vector<uint64_t> HotFuncs;
173-
parseMaps</*Cold=*/false>(HotFuncs, DE, Offset, Err);
174-
parseMaps</*Cold=*/true>(HotFuncs, DE, Offset, Err);
175+
uint64_t PrevAddress = 0;
176+
parseMaps</*Cold=*/false>(HotFuncs, PrevAddress, DE, Offset, Err);
177+
parseMaps</*Cold=*/true>(HotFuncs, PrevAddress, DE, Offset, Err);
175178
outs() << "BOLT-INFO: Parsed " << Maps.size() << " BAT entries\n";
176179
return errorToErrorCode(std::move(Err));
177180
}
178181

179182
template <bool Cold>
180183
void BoltAddressTranslation::parseMaps(std::vector<uint64_t> &HotFuncs,
181-
DataExtractor &DE, uint64_t &Offset,
182-
Error &Err) {
184+
uint64_t &PrevAddress, DataExtractor &DE,
185+
uint64_t &Offset, Error &Err) {
183186
const uint32_t NumFunctions = DE.getULEB128(&Offset, &Err);
184187
LLVM_DEBUG(dbgs() << "Parsing " << NumFunctions << (Cold ? " cold" : "")
185188
<< " functions\n");
186189
size_t HotIndex = 0;
187-
uint64_t PrevAddress = 0;
188190
for (uint32_t I = 0; I < NumFunctions; ++I) {
189191
const uint64_t Address = PrevAddress + DE.getULEB128(&Offset, &Err);
190192
PrevAddress = Address;
@@ -199,18 +201,20 @@ void BoltAddressTranslation::parseMaps(std::vector<uint64_t> &HotFuncs,
199201

200202
LLVM_DEBUG(dbgs() << "Parsing " << NumEntries << " entries for 0x"
201203
<< Twine::utohexstr(Address) << "\n");
202-
uint64_t InputOffset = 0, OutputOffset = 0;
204+
uint64_t InputOffset = 0;
203205
for (uint32_t J = 0; J < NumEntries; ++J) {
204206
const uint64_t OutputDelta = DE.getULEB128(&Offset, &Err);
207+
const uint64_t OutputAddress = PrevAddress + OutputDelta;
208+
const uint64_t OutputOffset = OutputAddress - Address;
209+
PrevAddress = OutputAddress;
205210
const int64_t InputDelta = DE.getSLEB128(&Offset, &Err);
206-
OutputOffset += OutputDelta;
207211
InputOffset += InputDelta;
208212
Map.insert(std::pair<uint32_t, uint32_t>(OutputOffset, InputOffset));
209-
LLVM_DEBUG(dbgs() << formatv("{0:x} -> {1:x} ({2}/{3}b -> {4}/{5}b)\n",
210-
OutputOffset, InputOffset, OutputDelta,
211-
encodeULEB128(OutputDelta, nulls()),
212-
InputDelta,
213-
encodeSLEB128(InputDelta, nulls())));
213+
LLVM_DEBUG(
214+
dbgs() << formatv("{0:x} -> {1:x} ({2}/{3}b -> {4}/{5}b), {6:x}\n",
215+
OutputOffset, InputOffset, OutputDelta,
216+
encodeULEB128(OutputDelta, nulls()), InputDelta,
217+
encodeSLEB128(InputDelta, nulls()), OutputAddress));
214218
}
215219
Maps.insert(std::pair<uint64_t, MapTy>(Address, Map));
216220
}

bolt/test/X86/merge-fdata-bat-mode.test

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ RUN: merge-fdata %S/Inputs/bat_profile_1.fdata \
44
RUN: %S/Inputs/bat_profile_2.fdata \
55
RUN: | FileCheck %s --check-prefix=CHECK-FDATA
66

7+
CHECK-FDATA: boltedcollection
78
CHECK-FDATA: 1 main 451 1 SolveCubic 0 0 302
8-
9-
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Check that merge-fdata tool doesn't spuriously print boltedcollection
2+
3+
RUN: merge-fdata %S/Inputs/blarge.fdata %S/Inputs/blarge.fdata \
4+
RUN: | FileCheck %s --check-prefix=CHECK-FDATA
5+
6+
CHECK-FDATA-NOT: boltedcollection

bolt/tools/merge-fdata/merge-fdata.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ void mergeLegacyProfiles(const SmallVectorImpl<std::string> &Filenames) {
329329
MergedProfile.insert_or_assign(Key, Count);
330330
}
331331

332-
if (BoltedCollection)
332+
if (BoltedCollection.value_or(false))
333333
output() << "boltedcollection\n";
334334
for (const auto &[Key, Value] : MergedProfile)
335335
output() << Key << " " << Value << "\n";

0 commit comments

Comments
 (0)