Skip to content

Commit 5b4edbd

Browse files
authored
Merge branch 'main' into hgh/libcxx/nodiscard-native_handle
2 parents ea08a3c + ace77c2 commit 5b4edbd

File tree

1,030 files changed

+16946
-9427
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,030 files changed

+16946
-9427
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/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/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();

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,16 +1896,6 @@ bool BinaryFunction::scanExternalRefs() {
18961896
}
18971897
}
18981898

1899-
// Inform BinaryContext that this function symbols will not be defined and
1900-
// relocations should not be created against them.
1901-
if (BC.HasRelocations) {
1902-
for (std::pair<const uint32_t, MCSymbol *> &LI : Labels)
1903-
BC.UndefinedSymbols.insert(LI.second);
1904-
for (MCSymbol *const EndLabel : FunctionEndLabels)
1905-
if (EndLabel)
1906-
BC.UndefinedSymbols.insert(EndLabel);
1907-
}
1908-
19091899
clearList(Relocations);
19101900
clearList(ExternallyReferencedOffsets);
19111901

@@ -3234,14 +3224,6 @@ void BinaryFunction::clearDisasmState() {
32343224
clearList(Instructions);
32353225
clearList(IgnoredBranches);
32363226
clearList(TakenBranches);
3237-
3238-
if (BC.HasRelocations) {
3239-
for (std::pair<const uint32_t, MCSymbol *> &LI : Labels)
3240-
BC.UndefinedSymbols.insert(LI.second);
3241-
for (MCSymbol *const EndLabel : FunctionEndLabels)
3242-
if (EndLabel)
3243-
BC.UndefinedSymbols.insert(EndLabel);
3244-
}
32453227
}
32463228

32473229
void BinaryFunction::setTrapOnEntry() {

bolt/lib/Core/BinarySection.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,10 @@ void BinarySection::emitAsData(MCStreamer &Streamer,
112112
RI = ROE;
113113

114114
// Skip undefined symbols.
115-
auto HasUndefSym = [this](const auto &Relocation) {
116-
return BC.UndefinedSymbols.count(Relocation.Symbol);
115+
auto HasUndefSym = [](const auto &Relocation) {
116+
return Relocation.Symbol && Relocation.Symbol->isTemporary() &&
117+
Relocation.Symbol->isUndefined() &&
118+
!Relocation.Symbol->isRegistered();
117119
};
118120

119121
if (std::any_of(ROI, ROE, HasUndefSym))

bolt/lib/Core/DynoStats.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ PrintDynoOpcodeStat("print-dyno-opcode-stats",
5151
namespace llvm {
5252
namespace bolt {
5353

54-
constexpr const char *DynoStats::Desc[];
55-
5654
bool DynoStats::operator<(const DynoStats &Other) const {
5755
return std::lexicographical_compare(
5856
&Stats[FIRST_DYNO_STAT], &Stats[LAST_DYNO_STAT],

0 commit comments

Comments
 (0)