Skip to content

Commit b9a6376

Browse files
committed
Merge from 'main' to 'sycl-web' (402 commits)
CONFLICT (content): Merge conflict in llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
2 parents 4de7a52 + d01237c commit b9a6376

File tree

1,594 files changed

+67066
-56692
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,594 files changed

+67066
-56692
lines changed

.ci/monolithic-linux.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ cmake -S ${MONOREPO_ROOT}/llvm -B ${BUILD_DIR} \
4949
-D LLVM_ENABLE_LLD=ON \
5050
-D CMAKE_CXX_FLAGS=-gmlt \
5151
-D BOLT_CLANG_EXE=/usr/bin/clang \
52-
-D LLVM_CCACHE_BUILD=ON
52+
-D LLVM_CCACHE_BUILD=ON \
53+
-D MLIR_ENABLE_BINDINGS_PYTHON=ON
5354

5455
echo "--- ninja"
5556
# Targets are not escaped as they are passed as separate arguments.

.ci/monolithic-windows.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ cmake -S ${MONOREPO_ROOT}/llvm -B ${BUILD_DIR} \
4848
-D LLVM_LIT_ARGS="-v --xunit-xml-output ${BUILD_DIR}/test-results.xml" \
4949
-D COMPILER_RT_BUILD_ORC=OFF \
5050
-D CMAKE_C_COMPILER_LAUNCHER=sccache \
51-
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache
51+
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache \
52+
-D MLIR_ENABLE_BINDINGS_PYTHON=ON
5253

5354
echo "--- ninja"
5455
# Targets are not escaped as they are passed as separate arguments.

.github/workflows/docs.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ on:
1515
paths:
1616
- 'llvm/docs/**'
1717
- 'clang/docs/**'
18+
- 'clang/include/clang/Basic/AttrDocs.td'
19+
- 'clang/include/clang/Driver/ClangOptionDocs.td'
20+
- 'clang/include/clang/Basic/DiagnosticDocs.td'
1821
- 'clang-tools-extra/docs/**'
1922
- 'lldb/docs/**'
2023
- 'libunwind/docs/**'
@@ -29,6 +32,9 @@ on:
2932
paths:
3033
- 'llvm/docs/**'
3134
- 'clang/docs/**'
35+
- 'clang/include/clang/Basic/AttrDocs.td'
36+
- 'clang/include/clang/Driver/ClangOptionDocs.td'
37+
- 'clang/include/clang/Basic/DiagnosticDocs.td'
3238
- 'clang-tools-extra/docs/**'
3339
- 'lldb/docs/**'
3440
- 'libunwind/docs/**'
@@ -64,6 +70,9 @@ jobs:
6470
- 'llvm/docs/**'
6571
clang:
6672
- 'clang/docs/**'
73+
- 'clang/include/clang/Basic/AttrDocs.td'
74+
- 'clang/include/clang/Driver/ClangOptionDocs.td'
75+
- 'clang/include/clang/Basic/DiagnosticDocs.td'
6776
clang-tools-extra:
6877
- 'clang-tools-extra/docs/**'
6978
lldb:

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ env:
4343

4444
jobs:
4545
stage1:
46+
if: github.repository_owner == 'llvm'
4647
runs-on:
4748
group: libcxx-runners-8
4849
continue-on-error: false
@@ -81,6 +82,7 @@ jobs:
8182
**/CMakeOutput.log
8283
**/crash_diagnostics/*
8384
stage2:
85+
if: github.repository_owner == 'llvm'
8486
runs-on:
8587
group: libcxx-runners-8
8688
needs: [ stage1 ]
@@ -130,6 +132,7 @@ jobs:
130132
**/CMakeOutput.log
131133
**/crash_diagnostics/*
132134
stage3:
135+
if: github.repository_owner == 'llvm'
133136
needs: [ stage1, stage2 ]
134137
continue-on-error: false
135138
strategy:

.github/workflows/pr-code-format.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ jobs:
4040
path: code-format-tools
4141

4242
- name: "Listed files"
43+
env:
44+
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
4345
run: |
4446
echo "Formatting files:"
45-
echo "${{ steps.changed-files.outputs.all_changed_files }}"
47+
echo "$CHANGED_FILES"
4648
4749
- name: Install clang-format
4850
uses: aminya/setup-cpp@v1

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,9 @@ class BinaryContext {
12301230
///
12311231
/// Return the pair where the first size is for the main part, and the second
12321232
/// size is for the cold one.
1233+
/// Modify BinaryBasicBlock::OutputAddressRange for each basic block in the
1234+
/// function in place so that BinaryBasicBlock::getOutputSize() gives the
1235+
/// emitted size of the basic block.
12331236
std::pair<size_t, size_t> calculateEmittedSize(BinaryFunction &BF,
12341237
bool FixBranches = true);
12351238

bolt/lib/Core/BinaryContext.cpp

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,14 +2331,36 @@ BinaryContext::calculateEmittedSize(BinaryFunction &BF, bool FixBranches) {
23312331
MCAsmLayout Layout(Assembler);
23322332
Assembler.layout(Layout);
23332333

2334+
// Obtain fragment sizes.
2335+
std::vector<uint64_t> FragmentSizes;
2336+
// Main fragment size.
23342337
const uint64_t HotSize =
23352338
Layout.getSymbolOffset(*EndLabel) - Layout.getSymbolOffset(*StartLabel);
2336-
const uint64_t ColdSize =
2337-
std::accumulate(SplitLabels.begin(), SplitLabels.end(), 0ULL,
2338-
[&](const uint64_t Accu, const LabelRange &Labels) {
2339-
return Accu + Layout.getSymbolOffset(*Labels.second) -
2340-
Layout.getSymbolOffset(*Labels.first);
2341-
});
2339+
FragmentSizes.push_back(HotSize);
2340+
// Split fragment sizes.
2341+
uint64_t ColdSize = 0;
2342+
for (const auto &Labels : SplitLabels) {
2343+
uint64_t Size = Layout.getSymbolOffset(*Labels.second) -
2344+
Layout.getSymbolOffset(*Labels.first);
2345+
FragmentSizes.push_back(Size);
2346+
ColdSize += Size;
2347+
}
2348+
2349+
// Populate new start and end offsets of each basic block.
2350+
uint64_t FragmentIndex = 0;
2351+
for (FunctionFragment &FF : BF.getLayout().fragments()) {
2352+
BinaryBasicBlock *PrevBB = nullptr;
2353+
for (BinaryBasicBlock *BB : FF) {
2354+
const uint64_t BBStartOffset = Layout.getSymbolOffset(*(BB->getLabel()));
2355+
BB->setOutputStartAddress(BBStartOffset);
2356+
if (PrevBB)
2357+
PrevBB->setOutputEndAddress(BBStartOffset);
2358+
PrevBB = BB;
2359+
}
2360+
if (PrevBB)
2361+
PrevBB->setOutputEndAddress(FragmentSizes[FragmentIndex]);
2362+
FragmentIndex++;
2363+
}
23422364

23432365
// Clean-up the effect of the code emission.
23442366
for (const MCSymbol &Symbol : Assembler.symbols()) {

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "llvm/Support/Regex.h"
4141
#include "llvm/Support/Timer.h"
4242
#include "llvm/Support/raw_ostream.h"
43+
#include "llvm/Support/xxhash.h"
4344
#include <functional>
4445
#include <limits>
4546
#include <numeric>
@@ -108,6 +109,13 @@ cl::opt<bool>
108109
cl::desc("try to preserve basic block alignment"),
109110
cl::cat(BoltOptCategory));
110111

112+
static cl::opt<bool> PrintOutputAddressRange(
113+
"print-output-address-range",
114+
cl::desc(
115+
"print output address range for each basic block in the function when"
116+
"BinaryFunction::print is called"),
117+
cl::Hidden, cl::cat(BoltOptCategory));
118+
111119
cl::opt<bool>
112120
PrintDynoStats("dyno-stats",
113121
cl::desc("print execution info based on profile"),
@@ -510,6 +518,11 @@ void BinaryFunction::print(raw_ostream &OS, std::string Annotation) {
510518
OS << BB->getName() << " (" << BB->size()
511519
<< " instructions, align : " << BB->getAlignment() << ")\n";
512520

521+
if (opts::PrintOutputAddressRange)
522+
OS << formatv(" Output Address Range: [{0:x}, {1:x}) ({2} bytes)\n",
523+
BB->getOutputAddressRange().first,
524+
BB->getOutputAddressRange().second, BB->getOutputSize());
525+
513526
if (isEntryPoint(*BB)) {
514527
if (MCSymbol *EntrySymbol = getSecondaryEntryPointSymbol(*BB))
515528
OS << " Secondary Entry Point: " << EntrySymbol->getName() << '\n';
@@ -3624,7 +3637,7 @@ size_t BinaryFunction::computeHash(bool UseDFS,
36243637
for (const BinaryBasicBlock *BB : Order)
36253638
HashString.append(hashBlock(BC, *BB, OperandHashFunc));
36263639

3627-
return Hash = std::hash<std::string>{}(HashString);
3640+
return Hash = llvm::xxh3_64bits(HashString);
36283641
}
36293642

36303643
void BinaryFunction::insertBasicBlocks(
@@ -4131,10 +4144,6 @@ void BinaryFunction::updateOutputValues(const BOLTLinker &Linker) {
41314144
if (!requiresAddressMap())
41324145
return;
41334146

4134-
// Output ranges should match the input if the body hasn't changed.
4135-
if (!isSimple() && !BC.HasRelocations)
4136-
return;
4137-
41384147
// AArch64 may have functions that only contains a constant island (no code).
41394148
if (getLayout().block_empty())
41404149
return;
@@ -4182,6 +4191,12 @@ void BinaryFunction::updateOutputValues(const BOLTLinker &Linker) {
41824191
? FF.getAddress() + FF.getImageSize()
41834192
: getOutputAddress() + getOutputSize());
41844193
}
4194+
4195+
// Reset output addresses for deleted blocks.
4196+
for (BinaryBasicBlock *BB : DeletedBasicBlocks) {
4197+
BB->setOutputStartAddress(0);
4198+
BB->setOutputEndAddress(0);
4199+
}
41854200
}
41864201

41874202
DebugAddressRangesVector BinaryFunction::getOutputAddressRanges() const {

bolt/lib/Core/HashUtilities.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,6 @@
1818
namespace llvm {
1919
namespace bolt {
2020

21-
/// Hashing a 64-bit integer to a 16-bit one.
22-
uint16_t hash_64_to_16(const uint64_t Hash) {
23-
uint16_t Res = (uint16_t)(Hash & 0xFFFF);
24-
Res ^= (uint16_t)((Hash >> 16) & 0xFFFF);
25-
Res ^= (uint16_t)((Hash >> 32) & 0xFFFF);
26-
Res ^= (uint16_t)((Hash >> 48) & 0xFFFF);
27-
return Res;
28-
}
29-
3021
std::string hashInteger(uint64_t Value) {
3122
std::string HashString;
3223
if (Value == 0)

bolt/lib/Profile/StaleProfileMatching.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "llvm/ADT/Bitfields.h"
3131
#include "llvm/ADT/Hashing.h"
3232
#include "llvm/Support/CommandLine.h"
33+
#include "llvm/Support/xxhash.h"
3334
#include "llvm/Transforms/Utils/SampleProfileInference.h"
3435

3536
#include <queue>
@@ -240,12 +241,12 @@ void BinaryFunction::computeBlockHashes() const {
240241
// Hashing complete instructions.
241242
std::string InstrHashStr = hashBlock(
242243
BC, *BB, [&](const MCOperand &Op) { return hashInstOperand(BC, Op); });
243-
uint64_t InstrHash = std::hash<std::string>{}(InstrHashStr);
244-
BlendedHashes[I].InstrHash = (uint16_t)hash_value(InstrHash);
244+
uint64_t InstrHash = llvm::xxh3_64bits(InstrHashStr);
245+
BlendedHashes[I].InstrHash = (uint16_t)InstrHash;
245246
// Hashing opcodes.
246247
std::string OpcodeHashStr = hashBlockLoose(BC, *BB);
247-
OpcodeHashes[I] = std::hash<std::string>{}(OpcodeHashStr);
248-
BlendedHashes[I].OpcodeHash = (uint16_t)hash_value(OpcodeHashes[I]);
248+
OpcodeHashes[I] = llvm::xxh3_64bits(OpcodeHashStr);
249+
BlendedHashes[I].OpcodeHash = (uint16_t)OpcodeHashes[I];
249250
}
250251

251252
// Initialize neighbor hash.
@@ -257,15 +258,15 @@ void BinaryFunction::computeBlockHashes() const {
257258
uint64_t SuccHash = OpcodeHashes[SuccBB->getIndex()];
258259
Hash = hashing::detail::hash_16_bytes(Hash, SuccHash);
259260
}
260-
BlendedHashes[I].SuccHash = (uint8_t)hash_value(Hash);
261+
BlendedHashes[I].SuccHash = (uint8_t)Hash;
261262

262263
// Append hashes of predecessors.
263264
Hash = 0;
264265
for (BinaryBasicBlock *PredBB : BB->predecessors()) {
265266
uint64_t PredHash = OpcodeHashes[PredBB->getIndex()];
266267
Hash = hashing::detail::hash_16_bytes(Hash, PredHash);
267268
}
268-
BlendedHashes[I].PredHash = (uint8_t)hash_value(Hash);
269+
BlendedHashes[I].PredHash = (uint8_t)Hash;
269270
}
270271

271272
// Assign hashes.
@@ -405,6 +406,8 @@ void matchWeightsByHashes(BinaryContext &BC,
405406
++BC.Stats.NumMatchedBlocks;
406407
BC.Stats.MatchedSampleCount += YamlBB.ExecCount;
407408
LLVM_DEBUG(dbgs() << " exact match\n");
409+
} else {
410+
LLVM_DEBUG(dbgs() << " loose match\n");
408411
}
409412
} else {
410413
LLVM_DEBUG(

0 commit comments

Comments
 (0)