Skip to content

Commit 568473c

Browse files
committed
LLVM and SPIRV-LLVM-Translator pulldown (WW43)
LLVM: llvm/llvm-project@2e2011d SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@d009cd4
2 parents 067b703 + 68e765c commit 568473c

File tree

2,845 files changed

+78532
-35404
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,845 files changed

+78532
-35404
lines changed

.github/workflows/docs.yml

Lines changed: 78 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,60 @@ on:
1515
paths:
1616
- 'llvm/docs/**'
1717
- 'clang/docs/**'
18+
- 'clang-tools-extra/docs/**'
19+
- 'lldb/docs/**'
20+
- 'libunwind/docs/**'
21+
- 'libcxx/docs/**'
22+
- 'libc/docs/**'
23+
- 'lld/docs/**'
1824
pull_request:
1925
paths:
2026
- 'llvm/docs/**'
2127
- 'clang/docs/**'
28+
- 'clang-tools-extra/docs/**'
29+
- 'lldb/docs/**'
30+
- 'libunwind/docs/**'
31+
- 'libcxx/docs/**'
32+
- 'libc/docs/**'
33+
- 'lld/docs/**'
2234

2335
jobs:
2436
check-docs-build:
2537
name: "Test documentation build"
2638
runs-on: ubuntu-latest
2739
steps:
28-
- name: Fetch LLVM sources
40+
# Don't fetch before checking for file changes to force the file changes
41+
# action to use the Github API in pull requests. If it's a push to a
42+
# branch we can't use the Github API to get the diff, so we need to have
43+
# a local checkout beforehand.
44+
- name: Fetch LLVM sources (Push)
45+
if: ${{ github.event_name == 'push' }}
46+
uses: actions/checkout@v4
47+
with:
48+
fetch-depth: 1
49+
- name: Get subprojects that have doc changes
50+
id: docs-changed-subprojects
51+
uses: tj-actions/changed-files@v39
52+
with:
53+
files_yaml: |
54+
llvm:
55+
- 'llvm/docs/**'
56+
clang:
57+
- 'clang/docs/**'
58+
clang-tools-extra:
59+
- 'clang-tools-extra/docs/**'
60+
lldb:
61+
- 'lldb/docs/**'
62+
libunwind:
63+
- 'libunwind/docs/**'
64+
libcxx:
65+
- 'libcxx/docs/**'
66+
libc:
67+
- 'libc/docs/**'
68+
lld:
69+
- 'lld/docs/**'
70+
- name: Fetch LLVM sources (PR)
71+
if: ${{ github.event_name == 'pull_request' }}
2972
uses: actions/checkout@v4
3073
with:
3174
fetch-depth: 1
@@ -40,24 +83,46 @@ jobs:
4083
- name: Install system dependencies
4184
run: |
4285
sudo apt-get update
43-
sudo apt-get install -y cmake ninja-build
44-
- name: Get subprojects that have doc changes
45-
id: docs-changed-subprojects
46-
uses: tj-actions/changed-files@v39
47-
with:
48-
files_yaml: |
49-
llvm:
50-
- 'llvm/docs/**'
51-
clang:
52-
- 'clang/docs/**'
86+
# swig and graphviz are lldb specific dependencies
87+
sudo apt-get install -y cmake ninja-build swig graphviz
5388
- name: Build LLVM docs
5489
if: steps.docs-changed-subprojects.outputs.llvm_any_changed == 'true'
5590
run: |
56-
cmake -B llvm-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_SPHINX=ON -DSPHINX_OUTPUT_HTML=ON -DSPHINX_OUTPUT_MAN=ON ./llvm
91+
cmake -B llvm-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_SPHINX=ON ./llvm
5792
TZ=UTC ninja -C llvm-build docs-llvm-html docs-llvm-man
5893
- name: Build Clang docs
5994
if: steps.docs-changed-subprojects.outputs.clang_any_changed == 'true'
6095
run: |
61-
cmake -B clang-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_SPHINX=ON -DSPHINX_OUTPUT_HTML=ON -DSPHINX_OUTPUT_MAN=ON ./llvm
96+
cmake -B clang-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_SPHINX=ON ./llvm
6297
TZ=UTC ninja -C clang-build docs-clang-html docs-clang-man
98+
- name: Build clang-tools-extra docs
99+
if: steps.docs-changed-subprojects.outputs.clang-tools-extra_any_changed == 'true'
100+
run: |
101+
cmake -B clang-tools-extra-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" -DLLVM_ENABLE_SPHINX=ON ./llvm
102+
TZ=UTC ninja -C clang-tools-extra-build docs-clang-tools-html docs-clang-tools-man
103+
- name: Build LLDB docs
104+
if: steps.docs-changed-subprojects.outputs.lldb_any_changed == 'true'
105+
run: |
106+
cmake -B lldb-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;lldb" -DLLVM_ENABLE_SPHINX=ON ./llvm
107+
TZ=UTC ninja -C lldb-build docs-lldb-html docs-lldb-man
108+
- name: Build libunwind docs
109+
if: steps.docs-changed-subprojects.outputs.libunwind_any_changed == 'true'
110+
run: |
111+
cmake -B libunwind-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES="libunwind" -DLLVM_ENABLE_SPHINX=ON ./runtimes
112+
TZ=UTC ninja -C libunwind-build docs-libunwind-html
113+
- name: Build libcxx docs
114+
if: steps.docs-changed-subprojects.outputs.libcxx_any_changed == 'true'
115+
run: |
116+
cmake -B libcxx-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES="libcxxabi;libcxx" -DLLVM_ENABLE_SPHINX=ON ./runtimes
117+
TZ=UTC ninja -C libcxx-build docs-libcxx-html
118+
- name: Build libc docs
119+
if: steps.docs-changed-subprojects.outputs.libc_any_changed == 'true'
120+
run: |
121+
cmake -B libc-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES="libc" -DLLVM_ENABLE_SPHINX=ON ./runtimes
122+
TZ=UTC ninja -C libc-build docs-libc-html
123+
- name: Build LLD docs
124+
if: steps.docs-changed-subprojects.outputs.lld_any_changed == 'true'
125+
run: |
126+
cmake -B lld-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="lld" -DLLVM_ENABLE_SPHINX=ON ./llvm
127+
TZ=UTC ninja -C lld-build docs-lld-html
63128

.github/workflows/gh_pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Install deps
2323
run: |
2424
sudo apt-get install -y doxygen graphviz ssh ninja-build
25-
sudo pip3 install 'sphinx==4.2.0' 'myst-parser==0.15.1' 'recommonmark==0.7.1'
25+
sudo pip3 install -r repo/llvm/docs/requirements.txt
2626
- name: Build Docs
2727
run: |
2828
mkdir -p $GITHUB_WORKSPACE/build

.github/workflows/libcxx-check-generated-files.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
paths:
55
- 'libcxx/**'
66

7+
permissions:
8+
contents: read
9+
710
jobs:
811
check_generated_files:
912
runs-on: ubuntu-latest

.github/workflows/release-tasks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
./llvm/utils/release/github-upload-release.py --token ${{ github.token }} --release ${{ steps.validate-tag.outputs.release-version }} upload --files ./*doxygen*.tar.xz
4949
5050
- name: Create Release Notes Artifact
51-
uses: actions/download-artifact@v3
51+
uses: actions/upload-artifact@v3
5252
with:
5353
name: release-notes
5454
path: docs-build/html-export/

bolt/include/bolt/Core/AddressMap.h

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// Helper class to create a mapping from input to output addresses needed for
10-
// updating debugging symbols and BAT. We emit an MCSection containing
11-
// <Input address, Output MCSymbol> pairs to the object file and JITLink will
12-
// transform this in <Input address, Output address> pairs. The linker output
13-
// can then be parsed and used to establish the mapping.
9+
// This file contains the declaration of the AddressMap class used for looking
10+
// up addresses in the output object.
1411
//
1512
//===----------------------------------------------------------------------===//
16-
//
13+
1714
#ifndef BOLT_CORE_ADDRESS_MAP_H
1815
#define BOLT_CORE_ADDRESS_MAP_H
1916

2017
#include "llvm/ADT/StringRef.h"
18+
#include "llvm/MC/MCSymbol.h"
2119

2220
#include <optional>
2321
#include <unordered_map>
@@ -30,26 +28,48 @@ namespace bolt {
3028

3129
class BinaryContext;
3230

31+
/// Helper class to create a mapping from input entities to output addresses
32+
/// needed for updating debugging symbols and BAT. We emit a section containing
33+
/// <Input entity, Output MCSymbol> pairs to the object file and JITLink will
34+
/// transform this in <Input entity, Output address> pairs. The linker output
35+
/// can then be parsed and used to establish the mapping.
36+
///
37+
/// The entities that can be mapped to output address are input addresses and
38+
/// labels (MCSymbol). Input addresses support one-to-many mapping.
3339
class AddressMap {
34-
using MapTy = std::unordered_multimap<uint64_t, uint64_t>;
35-
MapTy Map;
40+
static const char *const AddressSectionName;
41+
static const char *const LabelSectionName;
3642

37-
public:
38-
static const char *const SectionName;
43+
/// Map multiple <input address> to <output address>.
44+
using Addr2AddrMapTy = std::unordered_multimap<uint64_t, uint64_t>;
45+
Addr2AddrMapTy Address2AddressMap;
3946

47+
/// Map MCSymbol to its output address. Normally used for temp symbols that
48+
/// are not updated by the linker.
49+
using Label2AddrMapTy = DenseMap<const MCSymbol *, uint64_t>;
50+
Label2AddrMapTy Label2AddrMap;
51+
52+
public:
4053
static void emit(MCStreamer &Streamer, BinaryContext &BC);
41-
static AddressMap parse(StringRef Buffer, const BinaryContext &BC);
54+
static std::optional<AddressMap> parse(BinaryContext &BC);
4255

4356
std::optional<uint64_t> lookup(uint64_t InputAddress) const {
44-
auto It = Map.find(InputAddress);
45-
if (It != Map.end())
57+
auto It = Address2AddressMap.find(InputAddress);
58+
if (It != Address2AddressMap.end())
59+
return It->second;
60+
return std::nullopt;
61+
}
62+
63+
std::optional<uint64_t> lookup(const MCSymbol *Symbol) const {
64+
auto It = Label2AddrMap.find(Symbol);
65+
if (It != Label2AddrMap.end())
4666
return It->second;
4767
return std::nullopt;
4868
}
4969

50-
std::pair<MapTy::const_iterator, MapTy::const_iterator>
70+
std::pair<Addr2AddrMapTy::const_iterator, Addr2AddrMapTy::const_iterator>
5171
lookupAll(uint64_t InputAddress) const {
52-
return Map.equal_range(InputAddress);
72+
return Address2AddressMap.equal_range(InputAddress);
5373
}
5474
};
5575

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,14 +1721,7 @@ class BinaryFunction {
17211721
// Align data in code BFs minimum to CI alignment
17221722
if (!size() && hasIslandsInfo())
17231723
return getConstantIslandAlignment();
1724-
1725-
// Minimal code alignment on AArch64 and RISCV is 4
1726-
if (BC.isAArch64() || BC.isRISCV())
1727-
return 4;
1728-
1729-
// We have to use at least 2-byte alignment for functions because
1730-
// of C++ ABI.
1731-
return 2;
1724+
return BC.MIB->getMinFunctionAlignment();
17321725
}
17331726

17341727
Align getMinAlign() const { return Align(getMinAlignment()); }

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,6 +2077,12 @@ class MCPlusBuilder {
20772077
return BlocksVectorTy();
20782078
}
20792079

2080+
virtual uint16_t getMinFunctionAlignment() const {
2081+
// We have to use at least 2-byte alignment for functions because of C++
2082+
// ABI.
2083+
return 2;
2084+
}
2085+
20802086
// AliasMap caches a mapping of registers to the set of registers that
20812087
// alias (are sub or superregs of itself, including itself).
20822088
std::vector<BitVector> AliasMap;

bolt/lib/Core/AddressMap.cpp

Lines changed: 74 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,44 @@
1+
//===- bolt/Core/AddressMap.cpp - Input-output Address Map ----------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
19
#include "bolt/Core/AddressMap.h"
210
#include "bolt/Core/BinaryContext.h"
311
#include "bolt/Core/BinaryFunction.h"
12+
#include "bolt/Core/BinarySection.h"
413
#include "llvm/MC/MCStreamer.h"
514
#include "llvm/Support/DataExtractor.h"
615

716
namespace llvm {
817
namespace bolt {
918

10-
const char *const AddressMap::SectionName = ".bolt.address_map";
19+
const char *const AddressMap::AddressSectionName = ".bolt.addr2addr_map";
20+
const char *const AddressMap::LabelSectionName = ".bolt.label2addr_map";
1121

12-
static void emitLabel(MCStreamer &Streamer, uint64_t InputAddress,
13-
const MCSymbol *OutputLabel) {
22+
static void emitAddress(MCStreamer &Streamer, uint64_t InputAddress,
23+
const MCSymbol *OutputLabel) {
1424
Streamer.emitIntValue(InputAddress, 8);
1525
Streamer.emitSymbolValue(OutputLabel, 8);
1626
}
1727

28+
static void emitLabel(MCStreamer &Streamer, const MCSymbol *OutputLabel) {
29+
Streamer.emitIntValue(reinterpret_cast<uint64_t>(OutputLabel), 8);
30+
Streamer.emitSymbolValue(OutputLabel, 8);
31+
}
32+
1833
void AddressMap::emit(MCStreamer &Streamer, BinaryContext &BC) {
19-
Streamer.switchSection(BC.getDataSection(SectionName));
34+
// Mark map sections as link-only to avoid allocation in the output file.
35+
const unsigned Flags = BinarySection::getFlags(/*IsReadOnly*/ true,
36+
/*IsText*/ false,
37+
/*IsAllocatable*/ true);
38+
BC.registerOrUpdateSection(AddressSectionName, ELF::SHT_PROGBITS, Flags)
39+
.setLinkOnly();
40+
BC.registerOrUpdateSection(LabelSectionName, ELF::SHT_PROGBITS, Flags)
41+
.setLinkOnly();
2042

2143
for (const auto &[BFAddress, BF] : BC.getBinaryFunctions()) {
2244
if (!BF.requiresAddressMap())
@@ -26,37 +48,69 @@ void AddressMap::emit(MCStreamer &Streamer, BinaryContext &BC) {
2648
if (!BB.getLabel()->isDefined())
2749
continue;
2850

29-
emitLabel(Streamer, BFAddress + BB.getInputAddressRange().first,
30-
BB.getLabel());
51+
Streamer.switchSection(BC.getDataSection(LabelSectionName));
52+
emitLabel(Streamer, BB.getLabel());
3153

3254
if (!BB.hasLocSyms())
3355
continue;
3456

57+
Streamer.switchSection(BC.getDataSection(AddressSectionName));
3558
for (auto [Offset, Symbol] : BB.getLocSyms())
36-
emitLabel(Streamer, BFAddress + Offset, Symbol);
59+
emitAddress(Streamer, BFAddress + Offset, Symbol);
3760
}
3861
}
3962
}
4063

41-
AddressMap AddressMap::parse(StringRef Buffer, const BinaryContext &BC) {
42-
const auto EntrySize = 2 * BC.AsmInfo->getCodePointerSize();
43-
assert(Buffer.size() % EntrySize == 0 && "Unexpected address map size");
64+
std::optional<AddressMap> AddressMap::parse(BinaryContext &BC) {
65+
auto AddressMapSection = BC.getUniqueSectionByName(AddressSectionName);
66+
auto LabelMapSection = BC.getUniqueSectionByName(LabelSectionName);
4467

45-
DataExtractor DE(Buffer, BC.AsmInfo->isLittleEndian(),
46-
BC.AsmInfo->getCodePointerSize());
47-
DataExtractor::Cursor Cursor(0);
68+
if (!AddressMapSection && !LabelMapSection)
69+
return std::nullopt;
4870

4971
AddressMap Parsed;
50-
Parsed.Map.reserve(Buffer.size() / EntrySize);
5172

52-
while (Cursor && !DE.eof(Cursor)) {
53-
const auto Input = DE.getAddress(Cursor);
54-
const auto Output = DE.getAddress(Cursor);
55-
if (!Parsed.Map.count(Input))
56-
Parsed.Map.insert({Input, Output});
73+
const size_t EntrySize = 2 * BC.AsmInfo->getCodePointerSize();
74+
auto parseSection =
75+
[&](BinarySection &Section,
76+
function_ref<void(uint64_t, uint64_t)> InsertCallback) {
77+
StringRef Buffer = Section.getOutputContents();
78+
assert(Buffer.size() % EntrySize == 0 && "Unexpected address map size");
79+
80+
DataExtractor DE(Buffer, BC.AsmInfo->isLittleEndian(),
81+
BC.AsmInfo->getCodePointerSize());
82+
DataExtractor::Cursor Cursor(0);
83+
84+
while (Cursor && !DE.eof(Cursor)) {
85+
const uint64_t Input = DE.getAddress(Cursor);
86+
const uint64_t Output = DE.getAddress(Cursor);
87+
InsertCallback(Input, Output);
88+
}
89+
90+
assert(Cursor && "Error reading address map section");
91+
BC.deregisterSection(Section);
92+
};
93+
94+
if (AddressMapSection) {
95+
Parsed.Address2AddressMap.reserve(AddressMapSection->getOutputSize() /
96+
EntrySize);
97+
parseSection(*AddressMapSection, [&](uint64_t Input, uint64_t Output) {
98+
if (!Parsed.Address2AddressMap.count(Input))
99+
Parsed.Address2AddressMap.insert({Input, Output});
100+
});
101+
}
102+
103+
if (LabelMapSection) {
104+
Parsed.Label2AddrMap.reserve(LabelMapSection->getOutputSize() / EntrySize);
105+
parseSection(*LabelMapSection, [&](uint64_t Input, uint64_t Output) {
106+
assert(!Parsed.Label2AddrMap.count(
107+
reinterpret_cast<const MCSymbol *>(Input)) &&
108+
"Duplicate label entry detected.");
109+
Parsed.Label2AddrMap.insert(
110+
{reinterpret_cast<const MCSymbol *>(Input), Output});
111+
});
57112
}
58113

59-
assert(Cursor && "Error reading address map section");
60114
return Parsed;
61115
}
62116

0 commit comments

Comments
 (0)