Skip to content

Commit c146bd4

Browse files
committed
Merge branch 'main' into ptrauth-constants-in-data
2 parents eb7cc2f + ac40463 commit c146bd4

File tree

2,353 files changed

+67640
-36975
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,353 files changed

+67640
-36975
lines changed

.github/new-prs-labeler.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,16 @@ backend:AMDGPU:
717717
- '**/*amdgpu*/**'
718718
- '**/*AMDGPU*/**'
719719

720+
backend:NVPTX:
721+
- 'llvm/**/*nvvm*'
722+
- 'llvm/**/*NVVM*'
723+
- 'llvm/**/*nvptx*'
724+
- 'llvm/**/*NVPTX*'
725+
- 'llvm/**/*nvvm*/**'
726+
- 'llvm/**/*NVVM*/**'
727+
- 'llvm/**/*nvptx*/**'
728+
- 'llvm/**/*NVPTX*/**'
729+
720730
backend:RISC-V:
721731
- clang/**/*riscv*
722732
- clang/**/*RISCV*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ RUN cmake -B ./build -G Ninja ./llvm \
3737
-DLLVM_ENABLE_RUNTIMES="compiler-rt" \
3838
-DCMAKE_INSTALL_PREFIX="$LLVM_SYSROOT" \
3939
-DLLVM_ENABLE_PROJECTS="bolt;clang;lld;clang-tools-extra" \
40-
-DLLVM_DISTRIBUTION_COMPONENTS="lld;compiler-rt;clang-format" \
40+
-DLLVM_DISTRIBUTION_COMPONENTS="lld;compiler-rt;clang-format;scan-build" \
4141
-DCLANG_DEFAULT_LINKER="lld" \
4242
-DBOOTSTRAP_CLANG_PGO_TRAINING_DATA_SOURCE_DIR=/llvm-project-llvmorg-$LLVM_VERSION/llvm
4343

.github/workflows/release-binaries.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ jobs:
156156
rm build.tar.zst
157157
158158
- name: Build Stage 2
159+
# Re-enable once PGO builds are supported.
160+
if: false
159161
run: |
160162
ninja -C /mnt/build stage2-instrumented
161163

bolt/include/bolt/Core/BinarySection.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ class BinarySection {
284284
return true;
285285
}
286286
}
287+
bool isNote() const { return isELF() && ELFType == ELF::SHT_NOTE; }
287288
bool isReordered() const { return IsReordered; }
288289
bool isAnonymous() const { return IsAnonymous; }
289290
bool isRelro() const { return IsRelro; }

bolt/include/bolt/Core/DIEBuilder.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,9 @@ class DIEBuilder {
215215
/// Along with current CU, and DIE being processed and the new DIE offset to
216216
/// be updated, it takes in Parents vector that can be empty if this DIE has
217217
/// no parents.
218-
uint32_t
219-
finalizeDIEs(DWARFUnit &CU, DIE &Die,
220-
std::vector<std::optional<BOLTDWARF5AccelTableData *>> &Parents,
221-
uint32_t &CurOffset);
218+
uint32_t finalizeDIEs(DWARFUnit &CU, DIE &Die,
219+
std::optional<BOLTDWARF5AccelTableData *> Parent,
220+
uint32_t NumberParentsInChain, uint32_t &CurOffset);
222221

223222
void registerUnit(DWARFUnit &DU, bool NeedSort);
224223

bolt/include/bolt/Core/DebugNames.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,25 @@ class BOLTDWARF5AccelTableData : public DWARF5AccelTableData {
2424
BOLTDWARF5AccelTableData(const uint64_t DieOffset,
2525
const std::optional<uint64_t> DefiningParentOffset,
2626
const unsigned DieTag, const unsigned UnitID,
27-
const bool IsTU,
27+
const bool IsParentRoot, const bool IsTU,
2828
const std::optional<unsigned> SecondUnitID)
2929
: DWARF5AccelTableData(DieOffset, DefiningParentOffset, DieTag, UnitID,
3030
IsTU),
31-
SecondUnitID(SecondUnitID) {}
31+
SecondUnitID(SecondUnitID), IsParentRoot(IsParentRoot) {}
3232

3333
uint64_t getDieOffset() const { return DWARF5AccelTableData::getDieOffset(); }
3434
unsigned getDieTag() const { return DWARF5AccelTableData::getDieTag(); }
3535
unsigned getUnitID() const { return DWARF5AccelTableData::getUnitID(); }
3636
bool isTU() const { return DWARF5AccelTableData::isTU(); }
37+
bool isParentRoot() const { return IsParentRoot; }
3738
std::optional<unsigned> getSecondUnitID() const { return SecondUnitID; }
3839

3940
void setPatchOffset(uint64_t PatchOffset) { OffsetVal = PatchOffset; }
4041
uint64_t getPatchOffset() const { return std::get<uint64_t>(OffsetVal); }
4142

4243
private:
4344
std::optional<unsigned> SecondUnitID;
45+
bool IsParentRoot;
4446
};
4547

4648
class DWARF5AcceleratorTable {
@@ -57,6 +59,7 @@ class DWARF5AcceleratorTable {
5759
std::optional<BOLTDWARF5AccelTableData *>
5860
addAccelTableEntry(DWARFUnit &Unit, const DIE &Die,
5961
const std::optional<uint64_t> &DWOID,
62+
const uint32_t NumberParentsInChain,
6063
std::optional<BOLTDWARF5AccelTableData *> &Parent);
6164
/// Set current unit being processed.
6265
void setCurrentUnit(DWARFUnit &Unit, const uint64_t UnitStartOffset);

bolt/include/bolt/Core/GDBIndex.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//===-- bolt/Core/GDBIndex.h - GDB Index support ----------------*- C++ -*-===//
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+
///
9+
/// This file contains declaration of classes required for generation of
10+
/// .gdb_index section.
11+
///
12+
//===----------------------------------------------------------------------===//
13+
14+
#ifndef BOLT_CORE_GDB_INDEX_H
15+
#define BOLT_CORE_GDB_INDEX_H
16+
17+
#include "bolt/Core/BinaryContext.h"
18+
#include <vector>
19+
20+
namespace llvm {
21+
namespace bolt {
22+
23+
class GDBIndex {
24+
public:
25+
/// Contains information about TU so we can write out correct entries in GDB
26+
/// index.
27+
struct GDBIndexTUEntry {
28+
uint64_t UnitOffset;
29+
uint64_t TypeHash;
30+
uint64_t TypeDIERelativeOffset;
31+
};
32+
33+
private:
34+
BinaryContext &BC;
35+
36+
/// Entries for GDB Index Types CU List.
37+
using GDBIndexTUEntryType = std::vector<GDBIndexTUEntry>;
38+
GDBIndexTUEntryType GDBIndexTUEntryVector;
39+
40+
public:
41+
GDBIndex(BinaryContext &BC) : BC(BC) {}
42+
43+
std::mutex GDBIndexMutex;
44+
45+
/// Adds an GDBIndexTUEntry if .gdb_index section exists.
46+
void addGDBTypeUnitEntry(const GDBIndexTUEntry &&Entry);
47+
48+
/// Rewrite .gdb_index section if present.
49+
void updateGdbIndexSection(const CUOffsetMap &CUMap, const uint32_t NumCUs,
50+
DebugARangesSectionWriter &ARangesSectionWriter);
51+
52+
/// Returns all entries needed for Types CU list.
53+
const GDBIndexTUEntryType &getGDBIndexTUEntryVector() const {
54+
return GDBIndexTUEntryVector;
55+
}
56+
};
57+
58+
} // namespace bolt
59+
} // namespace llvm
60+
61+
#endif

bolt/include/bolt/Rewrite/MetadataManager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class MetadataManager {
2828
/// Register a new \p Rewriter.
2929
void registerRewriter(std::unique_ptr<MetadataRewriter> Rewriter);
3030

31+
/// Run initializers after sections are discovered.
32+
void runSectionInitializers();
33+
3134
/// Execute initialization of rewriters while functions are disassembled, but
3235
/// CFG is not yet built.
3336
void runInitializersPreCFG();

bolt/include/bolt/Rewrite/MetadataRewriter.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ class MetadataRewriter {
4545
/// Return name for the rewriter.
4646
StringRef getName() const { return Name; }
4747

48+
/// Run initialization after the binary is read and sections are identified,
49+
/// but before functions are discovered.
50+
virtual Error sectionInitializer() { return Error::success(); }
51+
4852
/// Interface for modifying/annotating functions in the binary based on the
4953
/// contents of the section. Functions are in pre-cfg state.
5054
virtual Error preCFGInitializer() { return Error::success(); }

bolt/include/bolt/Rewrite/MetadataRewriters.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class BinaryContext;
2121

2222
std::unique_ptr<MetadataRewriter> createLinuxKernelRewriter(BinaryContext &);
2323

24+
std::unique_ptr<MetadataRewriter> createBuildIDRewriter(BinaryContext &);
25+
2426
std::unique_ptr<MetadataRewriter> createPseudoProbeRewriter(BinaryContext &);
2527

2628
std::unique_ptr<MetadataRewriter> createSDTRewriter(BinaryContext &);

0 commit comments

Comments
 (0)