Skip to content

Commit 9391696

Browse files
committed
Merge branch 'main' into xegpu_simt_dist
2 parents 68b1750 + c5a5f43 commit 9391696

File tree

933 files changed

+28612
-9411
lines changed

Some content is hidden

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

933 files changed

+28612
-9411
lines changed

.ci/monolithic-linux.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@ if [[ -n "${CLEAR_CACHE:-}" ]]; then
2828
ccache --clear
2929
fi
3030

31+
mkdir -p artifacts/reproducers
32+
33+
# Make sure any clang reproducers will end up as artifacts.
34+
export CLANG_CRASH_DIAGNOSTICS_DIR=`realpath artifacts/reproducers`
35+
3136
function at-exit {
3237
retcode=$?
3338

34-
mkdir -p artifacts
3539
ccache --print-stats > artifacts/ccache_stats.txt
3640
cp "${BUILD_DIR}"/.ninja_log artifacts/.ninja_log
3741

@@ -58,9 +62,18 @@ export PIP_BREAK_SYSTEM_PACKAGES=1
5862
pip install -q -r "${MONOREPO_ROOT}"/mlir/python/requirements.txt
5963
pip install -q -r "${MONOREPO_ROOT}"/lldb/test/requirements.txt
6064
pip install -q -r "${MONOREPO_ROOT}"/.ci/requirements.txt
65+
66+
# Set the system llvm-symbolizer as preferred.
67+
export LLVM_SYMBOLIZER_PATH=`which llvm-symbolizer`
68+
[[ ! -f "${LLVM_SYMBOLIZER_PATH}" ]] && echo "llvm-symbolizer not found!"
69+
70+
# Set up all runtimes either way. libcxx is a dependency of LLDB.
71+
# It will not be built unless it is used.
6172
cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
6273
-D LLVM_ENABLE_PROJECTS="${projects}" \
74+
-D LLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
6375
-G Ninja \
76+
-D CMAKE_PREFIX_PATH="${HOME}/.local" \
6477
-D CMAKE_BUILD_TYPE=Release \
6578
-D LLVM_ENABLE_ASSERTIONS=ON \
6679
-D LLVM_BUILD_EXAMPLES=ON \
@@ -69,7 +82,10 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
6982
-D LLVM_ENABLE_LLD=ON \
7083
-D CMAKE_CXX_FLAGS=-gmlt \
7184
-D LLVM_CCACHE_BUILD=ON \
85+
-D LIBCXX_CXX_ABI=libcxxabi \
7286
-D MLIR_ENABLE_BINDINGS_PYTHON=ON \
87+
-D LLDB_ENABLE_PYTHON=ON \
88+
-D LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=ON \
7389
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}"
7490

7591
echo "--- ninja"

bolt/lib/Core/BinaryBasicBlock.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,7 @@ void BinaryBasicBlock::updateJumpTableSuccessors() {
372372
[](const BinaryBasicBlock *BB1, const BinaryBasicBlock *BB2) {
373373
return BB1->getInputOffset() < BB2->getInputOffset();
374374
});
375-
SuccessorBBs.erase(std::unique(SuccessorBBs.begin(), SuccessorBBs.end()),
376-
SuccessorBBs.end());
375+
SuccessorBBs.erase(llvm::unique(SuccessorBBs), SuccessorBBs.end());
377376

378377
for (BinaryBasicBlock *BB : SuccessorBBs)
379378
addSuccessor(BB);

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2376,7 +2376,7 @@ Error BinaryFunction::buildCFG(MCPlusBuilder::AllocatorIdTy AllocatorId) {
23762376
// Without doing jump table value profiling we don't have a use for extra
23772377
// (duplicate) branches.
23782378
llvm::sort(TakenBranches);
2379-
auto NewEnd = std::unique(TakenBranches.begin(), TakenBranches.end());
2379+
auto NewEnd = llvm::unique(TakenBranches);
23802380
TakenBranches.erase(NewEnd, TakenBranches.end());
23812381

23822382
for (std::pair<uint32_t, uint32_t> &Branch : TakenBranches) {

bolt/lib/Core/DebugNames.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,7 @@ void DWARF5AcceleratorTable::computeBucketCount() {
440440
for (const auto &E : Entries)
441441
Uniques.push_back(E.second.HashValue);
442442
array_pod_sort(Uniques.begin(), Uniques.end());
443-
std::vector<uint32_t>::iterator P =
444-
std::unique(Uniques.begin(), Uniques.end());
443+
std::vector<uint32_t>::iterator P = llvm::unique(Uniques);
445444

446445
UniqueHashCount = std::distance(Uniques.begin(), P);
447446

bolt/lib/Profile/YAMLProfileWriter.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,9 @@ std::vector<yaml::bolt::PseudoProbeInfo>
133133
YAMLProfileWriter::convertNodeProbes(NodeIdToProbes &NodeProbes) {
134134
struct BlockProbeInfoHasher {
135135
size_t operator()(const yaml::bolt::PseudoProbeInfo &BPI) const {
136-
auto HashCombine = [](auto &Range) {
137-
return llvm::hash_combine_range(Range.begin(), Range.end());
138-
};
139-
return llvm::hash_combine(HashCombine(BPI.BlockProbes),
140-
HashCombine(BPI.CallProbes),
141-
HashCombine(BPI.IndCallProbes));
136+
return llvm::hash_combine(llvm::hash_combine_range(BPI.BlockProbes),
137+
llvm::hash_combine_range(BPI.CallProbes),
138+
llvm::hash_combine_range(BPI.IndCallProbes));
142139
}
143140
};
144141

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@ UseGnuStack("use-gnu-stack",
237237
cl::ZeroOrMore,
238238
cl::cat(BoltCategory));
239239

240+
static cl::opt<uint64_t> CustomAllocationVMA(
241+
"custom-allocation-vma",
242+
cl::desc("use a custom address at which new code will be put, "
243+
"bypassing BOLT's logic to detect where to put code"),
244+
cl::Hidden, cl::cat(BoltCategory));
245+
240246
static cl::opt<bool>
241247
SequentialDisassembly("sequential-disassembly",
242248
cl::desc("performs disassembly sequentially"),
@@ -592,6 +598,25 @@ Error RewriteInstance::discoverStorage() {
592598

593599
FirstNonAllocatableOffset = NextAvailableOffset;
594600

601+
if (opts::CustomAllocationVMA) {
602+
// If user specified a custom address where we should start writing new
603+
// data, honor that.
604+
NextAvailableAddress = opts::CustomAllocationVMA;
605+
// Sanity check the user-supplied address and emit warnings if something
606+
// seems off.
607+
for (const ELF64LE::Phdr &Phdr : PHs) {
608+
switch (Phdr.p_type) {
609+
case ELF::PT_LOAD:
610+
if (NextAvailableAddress >= Phdr.p_vaddr &&
611+
NextAvailableAddress < Phdr.p_vaddr + Phdr.p_memsz) {
612+
BC->errs() << "BOLT-WARNING: user-supplied allocation vma 0x"
613+
<< Twine::utohexstr(NextAvailableAddress)
614+
<< " conflicts with ELF segment at 0x"
615+
<< Twine::utohexstr(Phdr.p_vaddr) << "\n";
616+
}
617+
}
618+
}
619+
}
595620
NextAvailableAddress = alignTo(NextAvailableAddress, BC->PageAlign);
596621
NextAvailableOffset = alignTo(NextAvailableOffset, BC->PageAlign);
597622

@@ -1055,10 +1080,11 @@ void RewriteInstance::discoverFileObjects() {
10551080
continue;
10561081
}
10571082

1058-
if (!Section->isText()) {
1083+
if (!Section->isText() || Section->isVirtual()) {
10591084
assert(SymbolType != SymbolRef::ST_Function &&
10601085
"unexpected function inside non-code section");
1061-
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: rejecting as symbol is not in code\n");
1086+
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: rejecting as symbol is not in code or "
1087+
"is in nobits section\n");
10621088
registerName(SymbolSize);
10631089
continue;
10641090
}

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2336,7 +2336,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
23362336
std::optional<Relocation>
23372337
createRelocation(const MCFixup &Fixup,
23382338
const MCAsmBackend &MAB) const override {
2339-
const MCFixupKindInfo &FKI = MAB.getFixupKindInfo(Fixup.getKind());
2339+
MCFixupKindInfo FKI = MAB.getFixupKindInfo(Fixup.getKind());
23402340

23412341
assert(FKI.TargetOffset == 0 && "0-bit relocation offset expected");
23422342
const uint64_t RelOffset = Fixup.getOffset();

bolt/lib/Target/X86/X86MCPlusBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2441,7 +2441,7 @@ class X86MCPlusBuilder : public MCPlusBuilder {
24412441
std::optional<Relocation>
24422442
createRelocation(const MCFixup &Fixup,
24432443
const MCAsmBackend &MAB) const override {
2444-
const MCFixupKindInfo &FKI = MAB.getFixupKindInfo(Fixup.getKind());
2444+
MCFixupKindInfo FKI = MAB.getFixupKindInfo(Fixup.getKind());
24452445

24462446
assert(FKI.TargetOffset == 0 && "0-bit relocation offset expected");
24472447
const uint64_t RelOffset = Fixup.getOffset();

bolt/test/X86/high-segments.s

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Check that we are able to rewrite binaries when we fail to identify a
2+
// suitable location to put new code and user supplies a custom one via
3+
// --custom-allocation-vma. This happens more obviously if the binary has
4+
// segments mapped to very high addresses.
5+
6+
// In this example, my.reserved.section is mapped to a segment to be loaded
7+
// at address 0x10000000000, while regular text should be at 0x200000. We
8+
// pick a vma in the middle at 0x700000 to carve space for BOLT to put data,
9+
// since BOLT's usual route of allocating after the last segment will put
10+
// code far away and that will blow up relocations from main.
11+
12+
// RUN: split-file %s %t
13+
// RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %t/main.s -o %t.o
14+
// RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-T %t/main.ls
15+
// RUN: llvm-bolt %t.exe -o %t.bolt --custom-allocation-vma=0x700000
16+
17+
//--- main.s
18+
.type reserved_space,@object
19+
.section .my.reserved.section,"awx",@nobits
20+
.globl reserved_space
21+
.p2align 4, 0x0
22+
reserved_space:
23+
.zero 0x80000000
24+
.size reserved_space, 0x80000000
25+
26+
.text
27+
.globl main
28+
.globl _start
29+
.type main, %function
30+
_start:
31+
main:
32+
.cfi_startproc
33+
nop
34+
nop
35+
nop
36+
retq
37+
.cfi_endproc
38+
.size main, .-main
39+
40+
//--- main.ls
41+
SECTIONS
42+
{
43+
.my.reserved.section 1<<40 : {
44+
*(.my.reserved.section);
45+
}
46+
} INSERT BEFORE .comment;

bolt/test/X86/nobits-symbol.s

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## Check that llvm-bolt doesn't choke on symbols defined in nobits sections.
2+
3+
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
4+
# RUN: %clang %cflags %t.o -o %t.exe
5+
# RUN: llvm-bolt %t.exe -o %t
6+
#
7+
8+
.type symbol_in_nobits,@object
9+
.section .my.nobits.section,"awx",@nobits
10+
.globl symbol_in_nobits
11+
.p2align 4, 0x0
12+
symbol_in_nobits:
13+
.zero 0x100000
14+
.size symbol_in_nobits, 0x100000
15+
16+
.text
17+
.globl main
18+
.type main, %function
19+
main:
20+
.cfi_startproc
21+
.LBB06:
22+
retq
23+
.cfi_endproc
24+
.size main, .-main

0 commit comments

Comments
 (0)