Skip to content

Commit 00cda23

Browse files
committed
[𝘀𝗽𝗿] changes introduced through rebase
Created using spr 1.3.4 [skip ci]
2 parents cca0f21 + 2091c74 commit 00cda23

File tree

3,180 files changed

+117735
-34194
lines changed

Some content is hidden

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

3,180 files changed

+117735
-34194
lines changed

.github/CODEOWNERS

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ clang/test/AST/Interp/ @tbaederr
5959
/mlir/Dialect/*/Transforms/Bufferize.cpp @matthias-springer
6060

6161
# Linalg Dialect in MLIR.
62-
/mlir/include/mlir/Dialect/Linalg @dcaballe @nicolasvasilache
63-
/mlir/lib/Dialect/Linalg @dcaballe @nicolasvasilache
62+
/mlir/include/mlir/Dialect/Linalg/* @dcaballe @nicolasvasilache
63+
/mlir/lib/Dialect/Linalg/* @dcaballe @nicolasvasilache
6464
/mlir/lib/Dialect/Linalg/Transforms/DecomposeLinalgOps.cpp @MaheshRavishankar @nicolasvasilache
6565
/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp @MaheshRavishankar @nicolasvasilache
6666
/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp @MaheshRavishankar @nicolasvasilache
@@ -77,14 +77,14 @@ clang/test/AST/Interp/ @tbaederr
7777
/mlir/**/*SME* @banach-space @dcaballe @nicolasvasilache
7878
/mlir/**/*SVE* @banach-space @dcaballe @nicolasvasilache
7979
/mlir/**/*VectorInterfaces* @dcaballe @nicolasvasilache
80-
/mlir/**/*VectorToSCF* @banach-space @dcaballe @nicolasvasilache @matthias-springer
80+
/mlir/**/*VectorToSCF* @banach-space @dcaballe @matthias-springer @nicolasvasilache
8181
/mlir/**/*VectorToLLVM* @banach-space @dcaballe @nicolasvasilache
8282
/mlir/**/*X86Vector* @aartbik @dcaballe @nicolasvasilache
83-
/mlir/include/mlir/Dialect/Vector @dcaballe @nicolasvasilache
84-
/mlir/lib/Dialect/Vector @dcaballe @nicolasvasilache
85-
/mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp @MaheshRavishankar @nicolasvasilache
86-
/mlir/**/*EmulateNarrowType* @hanhanW
83+
/mlir/include/mlir/Dialect/Vector/* @dcaballe @nicolasvasilache
84+
/mlir/lib/Dialect/Vector/* @dcaballe @nicolasvasilache
8785
/mlir/lib/Dialect/Vector/Transforms/* @hanhanW @nicolasvasilache
86+
/mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp @MaheshRavishankar @nicolasvasilache
87+
/mlir/**/*EmulateNarrowType* @dcaballe @hanhanW
8888

8989
# Presburger library in MLIR
9090
/mlir/**/*Presburger* @Groverkss @Superty
@@ -96,6 +96,7 @@ clang/test/AST/Interp/ @tbaederr
9696
# Transform Dialect in MLIR.
9797
/mlir/include/mlir/Dialect/Transform/* @ftynse @nicolasvasilache
9898
/mlir/lib/Dialect/Transform/* @ftynse @nicolasvasilache
99+
/mlir/**/*TransformOps* @ftynse @nicolasvasilache
99100

100101
# SPIR-V Dialect in MLIR.
101102
/mlir/**/SPIRV/ @antiagainst @kuhar
@@ -106,5 +107,21 @@ clang/test/AST/Interp/ @tbaederr
106107
# MLIR Sparsifier.
107108
/mlir/**/*SparseTensor*/ @aartbik @PeimingLiu @yinying-lisa-li @matthias-springer
108109

110+
# MLIR NVGPU Dialect
111+
/mlir/**/NVGPU*/ @grypp
112+
/mlir/test/**/CUDA/ @grypp
113+
114+
# MLIR NVVM Dialect in MLIR
115+
/mlir/**/LLVMIR/**/BasicPtxBuilderInterface* @grypp
116+
/mlir/**/NVVM*/ @grypp
117+
109118
# BOLT
110119
/bolt/ @aaupov @maksfb @rafaelauler @ayermolo @dcci
120+
121+
# Bazel build system.
122+
/utils/bazel/ @rupprecht
123+
124+
# InstallAPI and TextAPI
125+
/llvm/**/TextAPI/ @cyndyishida
126+
/clang/**/InstallAPI/ @cyndyishida
127+
/clang/tools/clang-installapi/ @cyndyishida

.github/new-prs-labeler.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,8 @@ backend:DirectX:
629629
- '**/*DirectX*/**'
630630
- '**/*DXIL*/**'
631631
- '**/*dxil*/**'
632+
- '**/*DXContainer*'
633+
- '**/*DXContainer*/**'
632634

633635
backend:SPIR-V:
634636
- clang/lib/Driver/ToolChains/SPIRV.*
@@ -933,3 +935,6 @@ openmp:libomp:
933935

934936
openmp:libomptarget:
935937
- any: ['openmp/**', '!openmp/runtime/**']
938+
939+
bazel:
940+
- utils/bazel/**

.github/workflows/llvm-tests.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jobs:
4242
BASELINE_REF: ${{ steps.vars.outputs.BASELINE_REF }}
4343
ABI_HEADERS: ${{ steps.vars.outputs.ABI_HEADERS }}
4444
BASELINE_VERSION_MAJOR: ${{ steps.vars.outputs.BASELINE_VERSION_MAJOR }}
45+
BASELINE_VERSION_MINOR: ${{ steps.vars.outputs.BASELINE_VERSION_MINOR }}
4546
LLVM_VERSION_MAJOR: ${{ steps.version.outputs.LLVM_VERSION_MAJOR }}
4647
LLVM_VERSION_MINOR: ${{ steps.version.outputs.LLVM_VERSION_MINOR }}
4748
LLVM_VERSION_PATCH: ${{ steps.version.outputs.LLVM_VERSION_PATCH }}
@@ -58,7 +59,14 @@ jobs:
5859
- name: Setup Variables
5960
id: vars
6061
run: |
61-
if [ ${{ steps.version.outputs.LLVM_VERSION_MINOR }} -ne 0 ] || [ ${{ steps.version.outputs.LLVM_VERSION_PATCH }} -eq 0 ]; then
62+
# C++ ABI:
63+
# 18.1.0 we aren't doing ABI checks.
64+
# 18.1.1 We want to check 18.1.0.
65+
# C ABI:
66+
# 18.1.0 We want to check 17.0.x
67+
# 18.1.1 We want to check 18.1.0
68+
echo "BASELINE_VERSION_MINOR=1" >> "$GITHUB_OUTPUT"
69+
if [ ${{ steps.version.outputs.LLVM_VERSION_PATCH }} -eq 0 ]; then
6270
{
6371
echo "BASELINE_VERSION_MAJOR=$(( ${{ steps.version.outputs.LLVM_VERSION_MAJOR }} - 1))"
6472
echo "ABI_HEADERS=llvm-c"
@@ -82,7 +90,7 @@ jobs:
8290
include:
8391
- name: build-baseline
8492
llvm_version_major: ${{ needs.abi-dump-setup.outputs.BASELINE_VERSION_MAJOR }}
85-
ref: llvmorg-${{ needs.abi-dump-setup.outputs.BASELINE_VERSION_MAJOR }}.0.0
93+
ref: llvmorg-${{ needs.abi-dump-setup.outputs.BASELINE_VERSION_MAJOR }}.${{ needs.abi-dump-setup.outputs.BASELINE_VERSION_MINOR }}.0
8694
repo: llvm/llvm-project
8795
- name: build-latest
8896
llvm_version_major: ${{ needs.abi-dump-setup.outputs.LLVM_VERSION_MAJOR }}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
- name: Install clang-format
5454
uses: aminya/setup-cpp@v1
5555
with:
56-
clangformat: 17.0.1
56+
clangformat: 18.1.1
5757

5858
- name: Setup Python env
5959
uses: actions/setup-python@v4

bolt/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ if (BOLT_ENABLE_RUNTIME)
4545
execute_process(COMMAND ls /proc/self/map_files
4646
RESULT_VARIABLE LS OUTPUT_QUIET ERROR_QUIET)
4747
if (LS)
48-
set(BOLT_ENABLE_RUNTIME OFF)
4948
message(WARNING
50-
"BOLT runtime is disabled as /proc/self/map_files is unreadable.")
49+
"BOLT runtime may not be able to read /proc/self/map_files. Please use
50+
`--instrumentation-binpath <path-to-instrumented-binary>` option.")
5151
endif()
5252
endif()
5353

bolt/docs/BAT.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ binary onto the original binary.
1414
# Usage
1515
`--enable-bat` flag controls the generation of BAT section. Sampled profile
1616
needs to be passed along with the optimized binary containing BAT section to
17-
`perf2bolt` which reads BAT section and produces fdata profile for the original
18-
binary. Note that YAML profile generation is not supported since BAT doesn't
19-
contain the metadata for input functions.
17+
`perf2bolt` which reads BAT section and produces profile for the original
18+
binary.
2019

2120
# Internals
2221
## Section contents
@@ -79,6 +78,8 @@ Hot indices are delta encoded, implicitly starting at zero.
7978
| ------ | ------| ----------- |
8079
| `Address` | Continuous, Delta, ULEB128 | Function address in the output binary |
8180
| `HotIndex` | Delta, ULEB128 | Cold functions only: index of corresponding hot function in hot functions table |
81+
| `FuncHash` | 8b | Hot functions only: function hash for input function |
82+
| `NumBlocks` | ULEB128 | Hot functions only: number of basic blocks in the original function |
8283
| `NumEntries` | ULEB128 | Number of address translation entries for a function |
8384
| `EqualElems` | ULEB128 | Hot functions only: number of equal offsets in the beginning of a function |
8485
| `BranchEntries` | Bitmask, `alignTo(EqualElems, 8)` bits | Hot functions only: if `EqualElems` is non-zero, bitmask denoting entries with `BRANCHENTRY` bit |
@@ -90,10 +91,12 @@ current function.
9091
### Address translation table
9192
Delta encoding means that only the difference with the previous corresponding
9293
entry is encoded. Input offsets implicitly start at zero.
93-
| Entry | Encoding | Description |
94-
| ------ | ------| ----------- |
95-
| `OutputOffset` | Continuous, Delta, ULEB128 | Function offset in output binary |
96-
| `InputOffset` | Optional, Delta, SLEB128 | Function offset in input binary with `BRANCHENTRY` LSB bit |
94+
| Entry | Encoding | Description | Branch/BB |
95+
| ------ | ------| ----------- | ------ |
96+
| `OutputOffset` | Continuous, Delta, ULEB128 | Function offset in output binary | Both |
97+
| `InputOffset` | Optional, Delta, SLEB128 | Function offset in input binary with `BRANCHENTRY` LSB bit | Both |
98+
| `BBHash` | Optional, 8b | Basic block hash in input binary | BB |
99+
| `BBIdx` | Optional, Delta, ULEB128 | Basic block index in input binary | BB |
97100

98101
`BRANCHENTRY` bit denotes whether a given offset pair is a control flow source
99102
(branch or call instruction). If not set, it signifies a control flow target

bolt/include/bolt/Core/DIEBuilder.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,13 @@ class DIEBuilder {
209209
void updateReferences();
210210

211211
/// Update the Offset and Size of DIE, populate DebugNames table.
212-
uint32_t finalizeDIEs(DWARFUnit &CU, DIE &Die, uint32_t &CurOffset);
212+
/// Along with current CU, and DIE being processed and the new DIE offset to
213+
/// be updated, it takes in Parents vector that can be empty if this DIE has
214+
/// no parents.
215+
uint32_t
216+
finalizeDIEs(DWARFUnit &CU, DIE &Die,
217+
std::vector<std::optional<BOLTDWARF5AccelTableData *>> &Parents,
218+
uint32_t &CurOffset);
213219

214220
void registerUnit(DWARFUnit &DU, bool NeedSort);
215221

bolt/include/bolt/Core/DebugNames.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ class BOLTDWARF5AccelTableData : public DWARF5AccelTableData {
3636
bool isTU() const { return DWARF5AccelTableData::isTU(); }
3737
std::optional<unsigned> getSecondUnitID() const { return SecondUnitID; }
3838

39+
void setPatchOffset(uint64_t PatchOffset) { OffsetVal = PatchOffset; }
40+
uint64_t getPatchOffset() const { return std::get<uint64_t>(OffsetVal); }
41+
3942
private:
4043
std::optional<unsigned> SecondUnitID;
4144
};
@@ -49,10 +52,12 @@ class DWARF5AcceleratorTable {
4952
Abbrev->~DebugNamesAbbrev();
5053
}
5154
/// Add DWARF5 Accelerator table entry.
52-
/// Input is DWARFUnit being processed, DIE that belongs to it, and potential
53-
/// SkeletonCU if the Unit comes from a DWO section.
54-
void addAccelTableEntry(DWARFUnit &Unit, const DIE &Die,
55-
const std::optional<uint64_t> &DWOID);
55+
/// Input is DWARFUnit being processed, DIE that belongs to it, potential
56+
/// DWOID if the Unit comes from a DWO section, and potential parent entry.
57+
std::optional<BOLTDWARF5AccelTableData *>
58+
addAccelTableEntry(DWARFUnit &Unit, const DIE &Die,
59+
const std::optional<uint64_t> &DWOID,
60+
std::optional<BOLTDWARF5AccelTableData *> &Parent);
5661
/// Set current unit being processed.
5762
void setCurrentUnit(DWARFUnit &Unit, const uint64_t UnitStartOffset);
5863
/// Emit Accelerator table.
@@ -121,6 +126,8 @@ class DWARF5AcceleratorTable {
121126
llvm::DenseMap<llvm::hash_code, uint64_t> StrCacheToOffsetMap;
122127
// Contains DWO ID to CUList Index.
123128
llvm::DenseMap<uint64_t, uint32_t> CUOffsetsToPatch;
129+
// Contains a map of Entry ID to Entry relative offset.
130+
llvm::DenseMap<uint64_t, uint32_t> EntryRelativeOffsets;
124131
/// Adds Unit to either CUList, LocalTUList or ForeignTUList.
125132
/// Input Unit being processed, and DWO ID if Unit is being processed comes
126133
/// from a DWO section.
@@ -143,7 +150,7 @@ class DWARF5AcceleratorTable {
143150
/// Write Entries.
144151
void writeEntries();
145152
/// Write an Entry.
146-
void writeEntry(const BOLTDWARF5AccelTableData &Entry);
153+
void writeEntry(BOLTDWARF5AccelTableData &Entry);
147154
/// Write augmentation_string for BOLT.
148155
void writeAugmentationString();
149156
/// Emit out Header for DWARF5 Accelerator table.

bolt/include/bolt/Core/MCPlus.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class MCAnnotation {
7373
kOffset, /// Offset in the function.
7474
kLabel, /// MCSymbol pointing to this instruction.
7575
kSize, /// Size of the instruction.
76+
kDynamicBranch, /// Jit instruction patched at runtime.
7677
kGeneric /// First generic annotation.
7778
};
7879

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,16 @@ class MCPlusBuilder {
11991199
/// Set instruction size.
12001200
void setSize(MCInst &Inst, uint32_t Size) const;
12011201

1202+
/// Check if the branch instruction could be modified at runtime.
1203+
bool isDynamicBranch(const MCInst &Inst) const;
1204+
1205+
/// Return ID for runtime-modifiable instruction.
1206+
std::optional<uint32_t> getDynamicBranchID(const MCInst &Inst) const;
1207+
1208+
/// Mark instruction as a dynamic branch, i.e. a branch that can be
1209+
/// overwritten at runtime.
1210+
void setDynamicBranch(MCInst &Inst, uint32_t ID) const;
1211+
12021212
/// Return MCSymbol that represents a target of this instruction at a given
12031213
/// operand number \p OpNum. If there's no symbol associated with
12041214
/// the operand - return nullptr.
@@ -1688,6 +1698,13 @@ class MCPlusBuilder {
16881698
llvm_unreachable("not implemented");
16891699
}
16901700

1701+
/// Create long conditional branch with a target-specific conditional code
1702+
/// \p CC.
1703+
virtual void createLongCondBranch(MCInst &Inst, const MCSymbol *Target,
1704+
unsigned CC, MCContext *Ctx) const {
1705+
llvm_unreachable("not implemented");
1706+
}
1707+
16911708
/// Reverses the branch condition in Inst and update its taken target to TBB.
16921709
///
16931710
/// Returns true on success.

bolt/include/bolt/Profile/BoltAddressTranslation.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,20 @@ class BoltAddressTranslation {
115115
/// Save function and basic block hashes used for metadata dump.
116116
void saveMetadata(BinaryContext &BC);
117117

118+
/// Returns BB hash by function output address (after BOLT) and basic block
119+
/// input offset.
120+
size_t getBBHash(uint64_t FuncOutputAddress, uint32_t BBInputOffset) const;
121+
122+
/// Returns BF hash by function output address (after BOLT).
123+
size_t getBFHash(uint64_t OutputAddress) const;
124+
125+
/// Returns BB index by function output address (after BOLT) and basic block
126+
/// input offset.
127+
unsigned getBBIndex(uint64_t FuncOutputAddress, uint32_t BBInputOffset) const;
128+
129+
/// True if a given \p Address is a function with translation table entry.
130+
bool isBATFunction(uint64_t Address) const { return Maps.count(Address); }
131+
118132
private:
119133
/// Helper to update \p Map by inserting one or more BAT entries reflecting
120134
/// \p BB for function located at \p FuncAddress. At least one entry will be
@@ -144,12 +158,19 @@ class BoltAddressTranslation {
144158

145159
std::map<uint64_t, MapTy> Maps;
146160

147-
using BBHashMap = std::unordered_map<uint32_t, size_t>;
161+
/// Map basic block input offset to a basic block index and hash pair.
162+
using BBHashMap = std::unordered_map<uint32_t, std::pair<unsigned, size_t>>;
148163
std::unordered_map<uint64_t, std::pair<size_t, BBHashMap>> FuncHashes;
149164

165+
/// Map a function to its basic blocks count
166+
std::unordered_map<uint64_t, size_t> NumBasicBlocksMap;
167+
150168
/// Links outlined cold bocks to their original function
151169
std::map<uint64_t, uint64_t> ColdPartSource;
152170

171+
/// Links output address of a main fragment back to input address.
172+
std::unordered_map<uint64_t, uint64_t> ReverseMap;
173+
153174
/// Identifies the address of a control-flow changing instructions in a
154175
/// translation map entry
155176
const static uint32_t BRANCHENTRY = 0x1;

bolt/include/bolt/Profile/DataAggregator.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,10 @@ class DataAggregator : public DataReader {
463463
/// Dump data structures into a file readable by llvm-bolt
464464
std::error_code writeAggregatedFile(StringRef OutputFilename) const;
465465

466+
/// Dump translated data structures into YAML
467+
std::error_code writeBATYAML(BinaryContext &BC,
468+
StringRef OutputFilename) const;
469+
466470
/// Filter out binaries based on PID
467471
void filterBinaryMMapInfo();
468472

bolt/include/bolt/Profile/YAMLProfileWriter.h

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

12+
#include "bolt/Profile/ProfileYAMLMapping.h"
1213
#include "llvm/Support/raw_ostream.h"
1314
#include <system_error>
1415

@@ -29,6 +30,9 @@ class YAMLProfileWriter {
2930

3031
/// Save execution profile for that instance.
3132
std::error_code writeProfile(const RewriteInstance &RI);
33+
34+
static yaml::bolt::BinaryFunctionProfile convert(const BinaryFunction &BF,
35+
bool UseDFS);
3236
};
3337

3438
} // namespace bolt

bolt/lib/Core/BinaryContext.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1939,7 +1939,13 @@ void BinaryContext::printInstruction(raw_ostream &OS, const MCInst &Instruction,
19391939
OS << Endl;
19401940
return;
19411941
}
1942-
InstPrinter->printInst(&Instruction, 0, "", *STI, OS);
1942+
if (std::optional<uint32_t> DynamicID =
1943+
MIB->getDynamicBranchID(Instruction)) {
1944+
OS << "\tjit\t" << MIB->getTargetSymbol(Instruction)->getName()
1945+
<< " # ID: " << DynamicID;
1946+
} else {
1947+
InstPrinter->printInst(&Instruction, 0, "", *STI, OS);
1948+
}
19431949
if (MIB->isCall(Instruction)) {
19441950
if (MIB->isTailCall(Instruction))
19451951
OS << " # TAILCALL ";

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3350,6 +3350,16 @@ void BinaryFunction::fixBranches() {
33503350

33513351
// Eliminate unnecessary conditional branch.
33523352
if (TSuccessor == FSuccessor) {
3353+
// FIXME: at the moment, we cannot safely remove static key branches.
3354+
if (MIB->isDynamicBranch(*CondBranch)) {
3355+
if (opts::Verbosity) {
3356+
BC.outs()
3357+
<< "BOLT-INFO: unable to remove redundant dynamic branch in "
3358+
<< *this << '\n';
3359+
}
3360+
continue;
3361+
}
3362+
33533363
BB->removeDuplicateConditionalSuccessor(CondBranch);
33543364
if (TSuccessor != NextBB)
33553365
BB->addBranchInstruction(TSuccessor);
@@ -3358,8 +3368,13 @@ void BinaryFunction::fixBranches() {
33583368

33593369
// Reverse branch condition and swap successors.
33603370
auto swapSuccessors = [&]() {
3361-
if (MIB->isUnsupportedBranch(*CondBranch))
3371+
if (MIB->isUnsupportedBranch(*CondBranch)) {
3372+
if (opts::Verbosity) {
3373+
BC.outs() << "BOLT-INFO: unable to swap successors in " << *this
3374+
<< '\n';
3375+
}
33623376
return false;
3377+
}
33633378
std::swap(TSuccessor, FSuccessor);
33643379
BB->swapConditionalSuccessors();
33653380
auto L = BC.scopeLock();

0 commit comments

Comments
 (0)