Skip to content

Commit 0796e45

Browse files
committed
Merge branch 'main' into metadata/rootsignature1.2
2 parents 97e733b + 26e370b commit 0796e45

File tree

2,129 files changed

+204119
-131065
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,129 files changed

+204119
-131065
lines changed

.github/renovate.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"config:recommended"
5+
],
6+
"includePaths": [".github/**"],
7+
"schedule": "* 0 * * 1",
8+
"minimumReleaseAge": "3 days",
9+
"assignees": ["boomanaiden154"],
10+
"ignorePaths": [".github/workflows/containers/**"],
11+
"groupName": "[Github] Update GHA Dependencies"
12+
}

.github/workflows/containers/github-action-ci/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM docker.io/library/ubuntu:24.04 as base
22
ENV LLVM_SYSROOT=/opt/llvm
33

44
FROM base as stage1-toolchain
5-
ENV LLVM_VERSION=21.1.0
5+
ENV LLVM_VERSION=21.1.1
66

77
RUN apt-get update && \
88
apt-get install -y \

.github/workflows/pr-code-lint.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333

3434
- name: Get changed files
3535
id: changed-files
36-
uses: step-security/changed-files@3dbe17c78367e7d60f00d78ae6781a35be47b4a1 # v45.0.1
36+
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5
3737
with:
3838
separator: ","
3939
skip_initial_fetch: true
@@ -47,10 +47,13 @@ jobs:
4747
echo "Changed files:"
4848
echo "$CHANGED_FILES"
4949
50+
# The clang tidy version should always be upgraded to the first version
51+
# of a release cycle (x.1.0) or the last version of a release cycle, or
52+
# if there have been relevant clang-format backports.
5053
- name: Install clang-tidy
5154
uses: aminya/setup-cpp@17c11551771948abc5752bbf3183482567c7caf0 # v1.1.1
5255
with:
53-
clang-tidy: 20.1.8
56+
clang-tidy: 21.1.0
5457

5558
- name: Setup Python env
5659
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,9 @@ class BinaryContext {
326326
/// Returns true if DWARF4 or lower is used.
327327
bool isDWARFLegacyUsed() const { return ContainsDwarfLegacy; }
328328

329+
/// Returns true if DWARFUnit is valid.
330+
bool isValidDwarfUnit(DWARFUnit &DU) const;
331+
329332
std::map<unsigned, DwarfLineTable> &getDwarfLineTables() {
330333
return DwarfLineTablesCUMap;
331334
}

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,6 @@ class BinaryFunction {
192192

193193
mutable MCSymbol *FunctionConstantIslandLabel{nullptr};
194194
mutable MCSymbol *FunctionColdConstantIslandLabel{nullptr};
195-
196-
// Returns constant island alignment
197-
uint16_t getAlignment() const { return sizeof(uint64_t); }
198195
};
199196

200197
static constexpr uint64_t COUNT_NO_PROFILE =
@@ -2114,9 +2111,7 @@ class BinaryFunction {
21142111
return *std::prev(CodeIter) <= *DataIter;
21152112
}
21162113

2117-
uint16_t getConstantIslandAlignment() const {
2118-
return Islands ? Islands->getAlignment() : 1;
2119-
}
2114+
uint16_t getConstantIslandAlignment() const;
21202115

21212116
/// If there is a constant island in the range [StartOffset, EndOffset),
21222117
/// return its address.
@@ -2168,6 +2163,11 @@ class BinaryFunction {
21682163
return Islands && !Islands->DataOffsets.empty();
21692164
}
21702165

2166+
/// Return true if the whole function is a constant island.
2167+
bool isDataObject() const {
2168+
return Islands && Islands->CodeOffsets.size() == 0;
2169+
}
2170+
21712171
bool isStartOfConstantIsland(uint64_t Offset) const {
21722172
return hasConstantIsland() && Islands->DataOffsets.count(Offset);
21732173
}

bolt/include/bolt/Core/DIEBuilder.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ class DIEBuilder {
217217
std::optional<BOLTDWARF5AccelTableData *> Parent,
218218
uint32_t NumberParentsInChain);
219219

220-
void registerUnit(DWARFUnit &DU, bool NeedSort);
220+
/// Returns true if DWARFUnit is registered successfully.
221+
bool registerUnit(DWARFUnit &DU, bool NeedSort);
221222

222223
/// \return the unique ID of \p U if it exists.
223224
std::optional<uint32_t> getUnitId(const DWARFUnit &DU);

bolt/include/bolt/Core/FunctionLayout.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,20 +232,31 @@ class FunctionLayout {
232232
return Blocks[Index];
233233
}
234234

235+
/// Return the basic block after the given basic block iterator in the layout
236+
/// or nullptr if the last basic block iterator is given.
237+
const BinaryBasicBlock *getBasicBlockAfter(block_const_iterator BlockIt,
238+
bool IgnoreSplits = true) const;
239+
240+
/// Returns the basic block after the given basic block in the layout or
241+
/// nullptr if the last basic block is given.
242+
///
243+
/// Note: prefer the version that takes the iterator as this function uses
244+
/// linear basic block lookup.
245+
const BinaryBasicBlock *getBasicBlockAfter(const BinaryBasicBlock *BB,
246+
bool IgnoreSplits = true) const;
247+
235248
/// Returns the basic block after the given basic block in the layout or
236249
/// nullptr if the last basic block is given.
250+
///
251+
/// Note: prefer the version that takes the iterator as this function uses
252+
/// linear basic block lookup.
237253
BinaryBasicBlock *getBasicBlockAfter(const BinaryBasicBlock *const BB,
238254
const bool IgnoreSplits = true) {
239255
return const_cast<BinaryBasicBlock *>(
240256
static_cast<const FunctionLayout &>(*this).getBasicBlockAfter(
241257
BB, IgnoreSplits));
242258
}
243259

244-
/// Returns the basic block after the given basic block in the layout or
245-
/// nullptr if the last basic block is given.
246-
const BinaryBasicBlock *getBasicBlockAfter(const BinaryBasicBlock *BB,
247-
bool IgnoreSplits = true) const;
248-
249260
/// True if the layout contains at least two non-empty fragments.
250261
bool isSplit() const;
251262

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class raw_ostream;
5151

5252
namespace bolt {
5353
class BinaryBasicBlock;
54+
class BinaryContext;
5455
class BinaryFunction;
5556

5657
/// Different types of indirect branches encountered during disassembly.
@@ -530,10 +531,15 @@ class MCPlusBuilder {
530531
return 0;
531532
}
532533

534+
/// Create a helper function to increment counter for Instrumentation
535+
virtual void createInstrCounterIncrFunc(BinaryContext &BC) {
536+
llvm_unreachable("not implemented");
537+
}
538+
533539
/// Create increment contents of target by 1 for Instrumentation
534-
virtual InstructionListType
535-
createInstrIncMemory(const MCSymbol *Target, MCContext *Ctx, bool IsLeaf,
536-
unsigned CodePointerSize) const {
540+
virtual InstructionListType createInstrIncMemory(const MCSymbol *Target,
541+
MCContext *Ctx, bool IsLeaf,
542+
unsigned CodePointerSize) {
537543
llvm_unreachable("not implemented");
538544
return InstructionListType();
539545
}

bolt/lib/Core/BinaryContext.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,10 +1624,26 @@ DWARFContext *BinaryContext::getDWOContext() const {
16241624
return &DWOCUs.begin()->second->getContext();
16251625
}
16261626

1627+
bool BinaryContext::isValidDwarfUnit(DWARFUnit &DU) const {
1628+
// Invalid DWARF unit with a DWOId but lacking a dwo_name.
1629+
if (DU.getDWOId() && !DU.isDWOUnit() &&
1630+
!DU.getUnitDIE().find(
1631+
{dwarf::DW_AT_dwo_name, dwarf::DW_AT_GNU_dwo_name})) {
1632+
this->outs() << "BOLT-ERROR: broken DWARF found in CU at offset 0x"
1633+
<< Twine::utohexstr(DU.getOffset()) << " (DWOId=0x"
1634+
<< Twine::utohexstr(*(DU.getDWOId()))
1635+
<< ", missing DW_AT_dwo_name / DW_AT_GNU_dwo_name)\n";
1636+
return false;
1637+
}
1638+
return true;
1639+
}
1640+
16271641
/// Handles DWO sections that can either be in .o, .dwo or .dwp files.
16281642
void BinaryContext::preprocessDWODebugInfo() {
16291643
for (const std::unique_ptr<DWARFUnit> &CU : DwCtx->compile_units()) {
16301644
DWARFUnit *const DwarfUnit = CU.get();
1645+
if (!isValidDwarfUnit(*DwarfUnit))
1646+
continue;
16311647
if (std::optional<uint64_t> DWOId = DwarfUnit->getDWOId()) {
16321648
std::string DWOName = dwarf::toString(
16331649
DwarfUnit->getUnitDIE().find(

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,33 @@ BinaryFunction::getBasicBlockContainingOffset(uint64_t Offset) {
284284
return (Offset < BB->getOffset() + BB->getOriginalSize()) ? BB : nullptr;
285285
}
286286

287+
uint16_t BinaryFunction::getConstantIslandAlignment() const {
288+
if (Islands == nullptr)
289+
return 1;
290+
291+
// For constant island inside a function, the default 8-byte alignment is
292+
// probably good enough.
293+
const uint16_t DefaultAlignment = sizeof(uint64_t);
294+
if (!isDataObject())
295+
return DefaultAlignment;
296+
297+
// If the constant island itself is a binary function, get its alignment
298+
// based on its size, original address, and its owning section's alignment.
299+
const uint64_t MaxAlignment =
300+
std::min(uint64_t(1) << llvm::countr_zero(getAddress()),
301+
OriginSection->getAlignment());
302+
const uint64_t MinAlignment =
303+
std::max((uint64_t)DefaultAlignment,
304+
uint64_t(1) << (63 - llvm::countl_zero(getSize())));
305+
uint64_t Alignment = std::min(MinAlignment, MaxAlignment);
306+
if (Alignment >> 16) {
307+
BC.errs() << "BOLT-ERROR: the constant island's alignment is too big: 0x"
308+
<< Twine::utohexstr(Alignment) << "\n";
309+
exit(1);
310+
}
311+
return (uint16_t)Alignment;
312+
}
313+
287314
void BinaryFunction::markUnreachableBlocks() {
288315
std::stack<BinaryBasicBlock *> Stack;
289316

@@ -3598,7 +3625,9 @@ void BinaryFunction::fixBranches() {
35983625
auto &MIB = BC.MIB;
35993626
MCContext *Ctx = BC.Ctx.get();
36003627

3601-
for (BinaryBasicBlock *BB : BasicBlocks) {
3628+
for (auto BBI = Layout.block_begin(), BBE = Layout.block_end(); BBI != BBE;
3629+
++BBI) {
3630+
BinaryBasicBlock *BB = *BBI;
36023631
const MCSymbol *TBB = nullptr;
36033632
const MCSymbol *FBB = nullptr;
36043633
MCInst *CondBranch = nullptr;
@@ -3612,7 +3641,7 @@ void BinaryFunction::fixBranches() {
36123641

36133642
// Basic block that follows the current one in the final layout.
36143643
const BinaryBasicBlock *const NextBB =
3615-
Layout.getBasicBlockAfter(BB, /*IgnoreSplits=*/false);
3644+
Layout.getBasicBlockAfter(BBI, /*IgnoreSplits*/ false);
36163645

36173646
if (BB->succ_size() == 1) {
36183647
// __builtin_unreachable() could create a conditional branch that

0 commit comments

Comments
 (0)