Skip to content

Commit dc89347

Browse files
authored
Merge branch 'main' into users/jmmartinez/spirv/amd_embed_bitcode_module
2 parents 0e5ddeb + 57dad86 commit dc89347

File tree

1,258 files changed

+26477
-9350
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,258 files changed

+26477
-9350
lines changed

.github/workflows/bazel-checks.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,26 @@ jobs:
3030
- name: Run Buildifier
3131
run: |
3232
buildifier --mode=check $(find ./utils/bazel -name *BUILD*)
33+
34+
bazel-build:
35+
name: "Bazel Build/Test"
36+
runs-on: llvm-premerge-linux-runners
37+
if: github.repository == 'llvm/llvm-project'
38+
steps:
39+
- name: Fetch LLVM sources
40+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
41+
# TODO(boomanaiden154): We should use a purpose built container for this. Move
42+
# over when we have fixed the issues with using custom containers with Github
43+
# ARC in GKE.
44+
- name: Setup System Dependencies
45+
run: |
46+
sudo apt-get update
47+
sudo apt-get install -y libmpfr-dev libpfm4-dev
48+
sudo curl -L https://github.com/bazelbuild/bazelisk/releases/download/v1.27.0/bazelisk-amd64.deb > /tmp/bazelisk.deb
49+
sudo apt-get install -y /tmp/bazelisk.deb
50+
rm /tmp/bazelisk.deb
51+
- name: Build/Test
52+
working-directory: utils/bazel
53+
run: |
54+
bazelisk test --config=ci --sandbox_base="" \
55+
@llvm-project//llvm/unittests:adt_tests

.github/workflows/build-ci-container-tooling.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ jobs:
3232
fail-fast: false
3333
matrix:
3434
include:
35-
- container-name: code-format
35+
- container-name: format
3636
test-command: 'cd $HOME && clang-format --version | grep version && git-clang-format -h | grep usage && black --version | grep black'
37-
- container-name: code-lint
37+
- container-name: lint
3838
test-command: 'cd $HOME && clang-tidy --version | grep version && clang-tidy-diff.py -h | grep usage'
3939
steps:
4040
- name: Checkout LLVM
@@ -52,7 +52,7 @@ jobs:
5252
with:
5353
container-name: ci-ubuntu-24.04-${{ matrix.container-name }}
5454
dockerfile: .github/workflows/containers/github-action-ci-tooling/Dockerfile
55-
target: ci-container-${{ matrix.container-name }}
55+
target: ci-container-code-${{ matrix.container-name }}
5656
test-command: ${{ matrix.test-command }}
5757

5858
push-ci-container:

.github/workflows/build-ci-container-windows.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
- build-ci-container-windows
5757
permissions:
5858
packages: write
59-
runs-on: windows-2022
59+
runs-on: ubuntu-24.04
6060
env:
6161
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6262
steps:
@@ -66,8 +66,12 @@ jobs:
6666
name: container
6767
- name: Push Container
6868
run: |
69-
docker load -i ${{ needs.build-ci-container-windows.outputs.container-filename }}
70-
docker tag ${{ needs.build-ci-container-windows.outputs.container-name-tag }} ${{ needs.build-ci-container-windows.outputs.container-name }}:latest
71-
docker login -u ${{ github.actor }} -p $env:GITHUB_TOKEN ghcr.io
72-
docker push ${{ needs.build-ci-container-windows.outputs.container-name-tag }}
73-
docker push ${{ needs.build-ci-container-windows.outputs.container-name }}:latest
69+
sudo apt-get update
70+
sudo apt-get install -y skopeo
71+
skopeo login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
72+
skopeo copy docker-archive:${{ needs.build-ci-container-windows.outputs.container-filename }} \
73+
--dest-compress-format zstd \
74+
docker://${{ needs.build-ci-container-windows.outputs.container-name-tag }}
75+
skopeo copy docker-archive:${{ needs.build-ci-container-windows.outputs.container-filename }} \
76+
--dest-compress-format zstd \
77+
docker://${{ needs.build-ci-container-windows.outputs.container-name }}:latest

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ jobs:
222222
python3 -m venv .venv
223223
source .venv/bin/activate
224224
python -m pip install psutil
225-
bash libcxx/utils/ci/run-buildbot ${{ matrix.config }}
225+
xcrun bash libcxx/utils/ci/run-buildbot ${{ matrix.config }}
226226
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
227227
if: always() # Upload artifacts even if the build or test suite fails
228228
with:

.github/workflows/premerge.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ jobs:
190190
with:
191191
max-size: "2000M"
192192
- name: Install Ninja
193-
uses: llvm/actions/install-ninja@42d80571b13f4599bbefbc7189728b64723c7f78 # main
193+
run: |
194+
brew install ninja
194195
- name: Build and Test
195196
run: |
196197
source <(git diff --name-only HEAD~1...HEAD | python3 .ci/compute_projects.py)

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,6 @@ class BinaryContext {
354354
/// Newly created segments.
355355
std::vector<SegmentInfo> NewSegments;
356356

357-
/// Symbols that are expected to be undefined in MCContext during emission.
358-
std::unordered_set<MCSymbol *> UndefinedSymbols;
359-
360357
/// [name] -> [BinaryData*] map used for global symbol resolution.
361358
using SymbolMapType = StringMap<BinaryData *>;
362359
SymbolMapType GlobalSymbols;
@@ -500,7 +497,7 @@ class BinaryContext {
500497
///
501498
/// As we fold identical functions, multiple symbols can point
502499
/// to the same BinaryFunction.
503-
std::unordered_map<const MCSymbol *, BinaryFunction *> SymbolToFunctionMap;
500+
DenseMap<const MCSymbol *, BinaryFunction *> SymbolToFunctionMap;
504501

505502
/// A mutex that is used to control parallel accesses to SymbolToFunctionMap
506503
mutable llvm::sys::RWMutex SymbolToFunctionMapMutex;

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,14 @@ class BinaryFunction {
281281
/// goto labels.
282282
std::set<uint64_t> ExternallyReferencedOffsets;
283283

284+
/// Relocations from data sections targeting internals of this function, i.e.
285+
/// some code not at an entry point. These include, but are not limited to,
286+
/// jump table relocations and computed goto tables.
287+
///
288+
/// Since relocations can be removed/deallocated, we store relocation offsets
289+
/// instead of pointers.
290+
DenseSet<uint64_t> InternalRefDataRelocations;
291+
284292
/// Offsets of indirect branches with unknown destinations.
285293
std::set<uint64_t> UnknownIndirectBranchOffsets;
286294

@@ -640,6 +648,20 @@ class BinaryFunction {
640648
Islands->CodeOffsets.emplace(Offset);
641649
}
642650

651+
/// Register a relocation from data section referencing code at a non-zero
652+
/// offset in this function.
653+
void registerInternalRefDataRelocation(uint64_t FuncOffset,
654+
uint64_t RelOffset) {
655+
assert(FuncOffset != 0 && "Relocation should reference function internals");
656+
registerReferencedOffset(FuncOffset);
657+
InternalRefDataRelocations.insert(RelOffset);
658+
const MCSymbol *ReferencedSymbol =
659+
getOrCreateLocalLabel(getAddress() + FuncOffset);
660+
661+
// Track the symbol mapping since it's used in relocation handling.
662+
BC.setSymbolToFunctionMap(ReferencedSymbol, this);
663+
}
664+
643665
/// Register an internal offset in a function referenced from outside.
644666
void registerReferencedOffset(uint64_t Offset) {
645667
ExternallyReferencedOffsets.emplace(Offset);
@@ -1299,6 +1321,12 @@ class BinaryFunction {
12991321
void addRelocation(uint64_t Address, MCSymbol *Symbol, uint32_t RelType,
13001322
uint64_t Addend, uint64_t Value);
13011323

1324+
/// Return locations (offsets) of data section relocations targeting internals
1325+
/// of this functions.
1326+
const DenseSet<uint64_t> &getInternalRefDataRelocations() const {
1327+
return InternalRefDataRelocations;
1328+
}
1329+
13021330
/// Return the name of the section this function originated from.
13031331
std::optional<StringRef> getOriginSectionName() const {
13041332
if (!OriginSection)

bolt/include/bolt/Rewrite/MetadataRewriters.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ class BinaryContext;
1919

2020
// The list of rewriter build functions.
2121

22-
std::unique_ptr<MetadataRewriter> createLinuxKernelRewriter(BinaryContext &);
23-
2422
std::unique_ptr<MetadataRewriter> createBuildIDRewriter(BinaryContext &);
2523

24+
std::unique_ptr<MetadataRewriter> createLinuxKernelRewriter(BinaryContext &);
25+
2626
std::unique_ptr<MetadataRewriter> createPseudoProbeRewriter(BinaryContext &);
2727

28+
std::unique_ptr<MetadataRewriter> createRSeqRewriter(BinaryContext &);
29+
2830
std::unique_ptr<MetadataRewriter> createSDTRewriter(BinaryContext &);
2931

3032
std::unique_ptr<MetadataRewriter> createGNUPropertyRewriter(BinaryContext &);

bolt/lib/Core/BinaryBasicBlock.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
namespace llvm {
2323
namespace bolt {
2424

25-
constexpr uint32_t BinaryBasicBlock::INVALID_OFFSET;
26-
2725
bool operator<(const BinaryBasicBlock &LHS, const BinaryBasicBlock &RHS) {
2826
return LHS.Index < RHS.Index;
2927
}

bolt/lib/Core/BinaryContext.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,17 @@ void BinaryContext::foldFunction(BinaryFunction &ChildBF,
15201520
}
15211521
ChildBF.getSymbols().clear();
15221522

1523+
// Reset function mapping for local symbols.
1524+
for (uint64_t RelOffset : ChildBF.getInternalRefDataRelocations()) {
1525+
const Relocation *Rel = getRelocationAt(RelOffset);
1526+
if (!Rel || !Rel->Symbol)
1527+
continue;
1528+
1529+
WriteSymbolMapLock.lock();
1530+
SymbolToFunctionMap[Rel->Symbol] = nullptr;
1531+
WriteSymbolMapLock.unlock();
1532+
}
1533+
15231534
// Move other names the child function is known under.
15241535
llvm::move(ChildBF.Aliases, std::back_inserter(ParentBF.Aliases));
15251536
ChildBF.Aliases.clear();

0 commit comments

Comments
 (0)