Skip to content

Commit f49dbe9

Browse files
committed
Merge branch 'main' into amdgpu-optimize-set-rounding
2 parents 06a0133 + 9731b77 commit f49dbe9

File tree

6,497 files changed

+483223
-198503
lines changed

Some content is hidden

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

6,497 files changed

+483223
-198503
lines changed

.ci/generate-buildkite-pipeline-premerge

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function add-dependencies() {
9191
echo "${project}"
9292
case ${project} in
9393
bolt)
94-
for p in lld llvm; do
94+
for p in clang lld llvm; do
9595
echo $p
9696
done
9797
;;
@@ -108,7 +108,7 @@ function add-dependencies() {
108108
compiler-rt|libc|openmp)
109109
echo clang lld
110110
;;
111-
flang|lldb)
111+
flang|lldb|libclc)
112112
for p in llvm clang; do
113113
echo $p
114114
done

.ci/monolithic-linux.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
4848
-D LLVM_LIT_ARGS="-v --xunit-xml-output ${BUILD_DIR}/test-results.xml --timeout=1200 --time-tests" \
4949
-D LLVM_ENABLE_LLD=ON \
5050
-D CMAKE_CXX_FLAGS=-gmlt \
51-
-D BOLT_CLANG_EXE=/usr/bin/clang \
5251
-D LLVM_CCACHE_BUILD=ON \
5352
-D MLIR_ENABLE_BINDINGS_PYTHON=ON
5453

.github/CODEOWNERS

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
clang/lib/AST/Interp/ @tbaederr
3636
clang/test/AST/Interp/ @tbaederr
3737

38+
/clang/include/clang/CIR @lanza @bcardosolopes
39+
/clang/lib/CIR @lanza @bcardosolopes
40+
/clang/tools/cir-* @lanza @bcardosolopes
41+
3842
/lldb/ @JDevlieghere
3943

4044
# MLIR Interfaces.
@@ -113,7 +117,15 @@ clang/test/AST/Interp/ @tbaederr
113117

114118
# MLIR NVVM Dialect in MLIR
115119
/mlir/**/LLVMIR/**/BasicPtxBuilderInterface* @grypp
116-
/mlir/**/NVVM*/ @grypp
120+
/mlir/**/NVVM* @grypp
121+
122+
# MLIR Python Bindings
123+
/mlir/test/python/ @ftynse @makslevental @stellaraccident
124+
/mlir/python/ @ftynse @makslevental @stellaraccident
125+
126+
# MLIR Mem2Reg/SROA
127+
/mlir/**/Transforms/Mem2Reg.* @moxinilian
128+
/mlir/**/Transforms/SROA.* @moxinilian
117129

118130
# BOLT
119131
/bolt/ @aaupov @maksfb @rafaelauler @ayermolo @dcci

.github/new-prs-labeler.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
BOLT:
2+
- bolt/**/*
3+
4+
ClangIR:
5+
- clang/include/clang/CIR/**/*
6+
- clang/lib/CIR/**/*
7+
- clang/tools/cir-*/**/*
8+
- clang/test/CIR/**/*
9+
110
clang:dataflow:
211
- clang/include/clang/Analysis/FlowSensitive/**/*
312
- clang/lib/Analysis/FlowSensitive/**/*
@@ -461,6 +470,7 @@ backend:m68k:
461470

462471
libc++:
463472
- libcxx/**
473+
- .github/workflows/libcxx-*
464474

465475
libc++abi:
466476
- libcxxabi/**
@@ -938,3 +948,6 @@ openmp:libomptarget:
938948

939949
bazel:
940950
- utils/bazel/**
951+
952+
offload:
953+
- offload/**

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,17 @@ jobs:
6161
]
6262
cc: [ 'clang-19' ]
6363
cxx: [ 'clang++-19' ]
64-
clang_tidy: [ 'ON' ]
6564
include:
6665
- config: 'generic-gcc'
6766
cc: 'gcc-13'
6867
cxx: 'g++-13'
69-
clang_tidy: 'OFF'
7068
steps:
7169
- uses: actions/checkout@v4
7270
- name: ${{ matrix.config }}.${{ matrix.cxx }}
7371
run: libcxx/utils/ci/run-buildbot ${{ matrix.config }}
7472
env:
7573
CC: ${{ matrix.cc }}
7674
CXX: ${{ matrix.cxx }}
77-
ENABLE_CLANG_TIDY: ${{ matrix.clang_tidy }}
7875
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
7976
if: always()
8077
with:
@@ -102,28 +99,23 @@ jobs:
10299
]
103100
cc: [ 'clang-19' ]
104101
cxx: [ 'clang++-19' ]
105-
clang_tidy: [ 'ON' ]
106102
include:
107103
- config: 'generic-gcc-cxx11'
108104
cc: 'gcc-13'
109105
cxx: 'g++-13'
110-
clang_tidy: 'OFF'
111106
- config: 'generic-cxx23'
112107
cc: 'clang-17'
113108
cxx: 'clang++-17'
114-
clang_tidy: 'OFF'
115109
- config: 'generic-cxx26'
116110
cc: 'clang-18'
117111
cxx: 'clang++-18'
118-
clang_tidy: 'ON'
119112
steps:
120113
- uses: actions/checkout@v4
121114
- name: ${{ matrix.config }}
122115
run: libcxx/utils/ci/run-buildbot ${{ matrix.config }}
123116
env:
124117
CC: ${{ matrix.cc }}
125118
CXX: ${{ matrix.cxx }}
126-
ENABLE_CLANG_TIDY: ${{ matrix.clang_tidy }}
127119
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
128120
if: always() # Upload artifacts even if the build or test suite fails
129121
with:
@@ -188,7 +180,6 @@ jobs:
188180
env:
189181
CC: clang-19
190182
CXX: clang++-19
191-
ENABLE_CLANG_TIDY: "OFF"
192183
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
193184
if: always()
194185
with:

bolt/docs/BAT.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ Hot indices are delta encoded, implicitly starting at zero.
8181
| `FuncHash` | 8b | Function hash for input function | Hot |
8282
| `NumBlocks` | ULEB128 | Number of basic blocks in the original function | Hot |
8383
| `NumSecEntryPoints` | ULEB128 | Number of secondary entry points in the original function | Hot |
84+
| `ColdInputSkew` | ULEB128 | Skew to apply to all input offsets | Cold |
8485
| `NumEntries` | ULEB128 | Number of address translation entries for a function | Both |
85-
| `EqualElems` | ULEB128 | Number of equal offsets in the beginning of a function | Hot |
86-
| `BranchEntries` | Bitmask, `alignTo(EqualElems, 8)` bits | If `EqualElems` is non-zero, bitmask denoting entries with `BRANCHENTRY` bit | Hot |
86+
| `EqualElems` | ULEB128 | Number of equal offsets in the beginning of a function | Both |
87+
| `BranchEntries` | Bitmask, `alignTo(EqualElems, 8)` bits | If `EqualElems` is non-zero, bitmask denoting entries with `BRANCHENTRY` bit | Both |
8788

8889
Function header is followed by *Address Translation Table* with `NumEntries`
8990
total entries, and *Secondary Entry Points* table with `NumSecEntryPoints`
@@ -99,8 +100,8 @@ entry is encoded. Input offsets implicitly start at zero.
99100
| `BBHash` | Optional, 8b | Basic block hash in input binary | BB |
100101
| `BBIdx` | Optional, Delta, ULEB128 | Basic block index in input binary | BB |
101102

102-
For hot fragments, the table omits the first `EqualElems` input offsets
103-
where the input offset equals output offset.
103+
The table omits the first `EqualElems` input offsets where the input offset
104+
equals output offset.
104105

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

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "bolt/Core/JumpTable.h"
2121
#include "bolt/Core/MCPlusBuilder.h"
2222
#include "bolt/RuntimeLibs/RuntimeLibrary.h"
23+
#include "llvm/ADT/AddressRanges.h"
2324
#include "llvm/ADT/ArrayRef.h"
2425
#include "llvm/ADT/StringMap.h"
2526
#include "llvm/ADT/iterator.h"
@@ -726,6 +727,9 @@ class BinaryContext {
726727
uint64_t OldTextSectionOffset{0};
727728
uint64_t OldTextSectionSize{0};
728729

730+
/// Area in the input binary reserved for BOLT.
731+
AddressRange BOLTReserved;
732+
729733
/// Address of the code/function that is executed before any other code in
730734
/// the binary.
731735
std::optional<uint64_t> StartFunctionAddress;

bolt/include/bolt/Core/BinaryData.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ class BinaryData {
107107
std::vector<MCSymbol *> &getSymbols() { return Symbols; }
108108

109109
bool hasName(StringRef Name) const;
110-
bool hasNameRegex(StringRef Name) const;
111110
bool nameStartsWith(StringRef Prefix) const;
112111

113112
bool hasSymbol(const MCSymbol *Symbol) const {

bolt/include/bolt/Passes/BinaryPasses.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,7 @@ class PrintProfileStats : public BinaryFunctionPass {
400400
/// dyno stats categories.
401401
class PrintProgramStats : public BinaryFunctionPass {
402402
public:
403-
explicit PrintProgramStats(const cl::opt<bool> &PrintPass)
404-
: BinaryFunctionPass(PrintPass) {}
403+
explicit PrintProgramStats() : BinaryFunctionPass(false) {}
405404

406405
const char *getName() const override { return "print-stats"; }
407406
bool shouldPrint(const BinaryFunction &) const override { return false; }

bolt/include/bolt/Profile/BoltAddressTranslation.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ class BoltAddressTranslation {
149149
/// entries in function address translation map.
150150
APInt calculateBranchEntriesBitMask(MapTy &Map, size_t EqualElems);
151151

152-
/// Calculate the number of equal offsets (output = input) in the beginning
153-
/// of the function.
154-
size_t getNumEqualOffsets(const MapTy &Map) const;
152+
/// Calculate the number of equal offsets (output = input - skew) in the
153+
/// beginning of the function.
154+
size_t getNumEqualOffsets(const MapTy &Map, uint32_t Skew) const;
155155

156156
std::map<uint64_t, MapTy> Maps;
157157

bolt/include/bolt/Profile/DataAggregator.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,8 @@ class DataAggregator : public DataReader {
198198
/// A trace is region of code executed between two LBR entries supplied in
199199
/// execution order.
200200
///
201-
/// Return true if the trace is valid, false otherwise.
202-
bool
203-
recordTrace(BinaryFunction &BF, const LBREntry &First, const LBREntry &Second,
204-
uint64_t Count,
205-
SmallVector<std::pair<uint64_t, uint64_t>, 16> &Branches) const;
206-
207201
/// Return a vector of offsets corresponding to a trace in a function
208-
/// (see recordTrace() above).
202+
/// if the trace is valid, std::nullopt otherwise.
209203
std::optional<SmallVector<std::pair<uint64_t, uint64_t>, 16>>
210204
getFallthroughsInTrace(BinaryFunction &BF, const LBREntry &First,
211205
const LBREntry &Second, uint64_t Count = 1) const;

bolt/include/bolt/Rewrite/RewriteInstance.h

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ class RewriteInstance {
9797
/// from meta data in the file.
9898
void discoverFileObjects();
9999

100+
/// Check if the input binary has a space reserved for BOLT and use it for new
101+
/// section allocations if found.
102+
void discoverBOLTReserved();
103+
100104
/// Check whether we should use DT_FINI or DT_FINI_ARRAY for instrumentation.
101105
/// DT_FINI is preferred; DT_FINI_ARRAY is only used when no DT_FINI entry was
102106
/// found.
@@ -368,13 +372,6 @@ class RewriteInstance {
368372
/// rewritten binary.
369373
void patchBuildID();
370374

371-
/// Return file offset corresponding to a given virtual address.
372-
uint64_t getFileOffsetFor(uint64_t Address) {
373-
assert(Address >= NewTextSegmentAddress &&
374-
"address in not in the new text segment");
375-
return Address - NewTextSegmentAddress + NewTextSegmentOffset;
376-
}
377-
378375
/// Return file offset corresponding to a virtual \p Address.
379376
/// Return 0 if the address has no mapping in the file, including being
380377
/// part of .bss section.
@@ -398,9 +395,6 @@ class RewriteInstance {
398395
/// Return true if the section holds debug information.
399396
static bool isDebugSection(StringRef SectionName);
400397

401-
/// Return true if the section holds linux kernel symbol information.
402-
static bool isKSymtabSection(StringRef SectionName);
403-
404398
/// Adds Debug section to overwrite.
405399
static void addToDebugSectionsToOverwrite(const char *Section) {
406400
DebugSectionsToOverwrite.emplace_back(Section);
@@ -432,10 +426,18 @@ class RewriteInstance {
432426
/// Section name used for extra BOLT code in addition to .text.
433427
static StringRef getBOLTTextSectionName() { return ".bolt.text"; }
434428

429+
/// Symbol markers for BOLT reserved area.
430+
static StringRef getBOLTReservedStart() { return "__bolt_reserved_start"; }
431+
static StringRef getBOLTReservedEnd() { return "__bolt_reserved_end"; }
432+
435433
/// Common section names.
436434
static StringRef getEHFrameSectionName() { return ".eh_frame"; }
435+
static StringRef getEHFrameHdrSectionName() { return ".eh_frame_hdr"; }
437436
static StringRef getRelaDynSectionName() { return ".rela.dyn"; }
438437

438+
/// FILE symbol name used for local fragments of global functions.
439+
static StringRef getBOLTFileSymbolName() { return "bolt-pseudo.o"; }
440+
439441
/// An instance of the input binary we are processing, externally owned.
440442
llvm::object::ELFObjectFileBase *InputFile;
441443

@@ -500,6 +502,9 @@ class RewriteInstance {
500502
/// Store all non-zero symbols in this map for a quick address lookup.
501503
std::map<uint64_t, llvm::object::SymbolRef> FileSymRefs;
502504

505+
/// FILE symbols used for disambiguating split function parents.
506+
std::vector<ELFSymbolRef> FileSymbols;
507+
503508
std::unique_ptr<DWARFRewriter> DebugInfoRewriter;
504509

505510
std::unique_ptr<BoltAddressTranslation> BAT;

bolt/include/bolt/Utils/NameResolver.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,23 @@ class NameResolver {
2828
static constexpr char Sep = '/';
2929

3030
public:
31-
/// Return unique version of the \p Name in the form "Name<Sep><Number>".
31+
/// Return the number of uniquified versions of a given \p Name.
32+
uint64_t getUniquifiedNameCount(StringRef Name) const {
33+
if (Counters.contains(Name))
34+
return Counters.at(Name);
35+
return 0;
36+
}
37+
38+
/// Return unique version of the \p Name in the form "Name<Sep><ID>".
39+
std::string getUniqueName(StringRef Name, const uint64_t ID) const {
40+
return (Name + Twine(Sep) + Twine(ID)).str();
41+
}
42+
43+
/// Register new version of \p Name and return unique version in the form
44+
/// "Name<Sep><Number>".
3245
std::string uniquify(StringRef Name) {
3346
const uint64_t ID = ++Counters[Name];
34-
return (Name + Twine(Sep) + Twine(ID)).str();
47+
return getUniqueName(Name, ID);
3548
}
3649

3750
/// For uniquified \p Name, return the original form (that may no longer be

bolt/lib/Core/BinaryContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1880,7 +1880,7 @@ MarkerSymType BinaryContext::getMarkerType(const SymbolRef &Symbol) const {
18801880
// For aarch64 and riscv, the ABI defines mapping symbols so we identify data
18811881
// in the code section (see IHI0056B). $x identifies a symbol starting code or
18821882
// the end of a data chunk inside code, $d identifies start of data.
1883-
if ((!isAArch64() && !isRISCV()) || ELFSymbolRef(Symbol).getSize())
1883+
if (isX86() || ELFSymbolRef(Symbol).getSize())
18841884
return MarkerSymType::NONE;
18851885

18861886
Expected<StringRef> NameOrError = Symbol.getName();

bolt/lib/Core/BinaryData.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,6 @@ bool BinaryData::hasName(StringRef Name) const {
5555
return false;
5656
}
5757

58-
bool BinaryData::hasNameRegex(StringRef NameRegex) const {
59-
Regex MatchName(NameRegex);
60-
for (const MCSymbol *Symbol : Symbols)
61-
if (MatchName.match(Symbol->getName()))
62-
return true;
63-
return false;
64-
}
65-
6658
bool BinaryData::nameStartsWith(StringRef Prefix) const {
6759
for (const MCSymbol *Symbol : Symbols)
6860
if (Symbol->getName().starts_with(Prefix))

bolt/lib/Core/BinaryEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ void BinaryEmitter::emitFunctionBody(BinaryFunction &BF, FunctionFragment &FF,
512512

513513
// Emit sized NOPs via MCAsmBackend::writeNopData() interface on x86.
514514
// This is a workaround for invalid NOPs handling by asm/disasm layer.
515-
if (BC.MIB->isNoop(Instr) && BC.isX86()) {
515+
if (BC.isX86() && BC.MIB->isNoop(Instr)) {
516516
if (std::optional<uint32_t> Size = BC.MIB->getSize(Instr)) {
517517
SmallString<15> Code;
518518
raw_svector_ostream VecOS(Code);

0 commit comments

Comments
 (0)