Skip to content

Commit 404f3db

Browse files
authored
Merge branch 'main' into llvm/enum-kind-bitcode
2 parents 228d30a + 954a3de commit 404f3db

File tree

2,619 files changed

+173039
-235813
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,619 files changed

+173039
-235813
lines changed

.ci/compute-projects.sh

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ function compute-projects-to-test() {
1818
shift
1919
projects=${@}
2020
for project in ${projects}; do
21+
echo "${project}"
2122
case ${project} in
2223
lld)
23-
for p in lld bolt cross-project-tests; do
24+
for p in bolt cross-project-tests; do
2425
echo $p
2526
done
2627
;;
2728
llvm)
28-
for p in llvm bolt clang clang-tools-extra lld lldb mlir polly; do
29+
for p in bolt clang clang-tools-extra lld lldb mlir polly; do
2930
echo $p
3031
done
3132
# Flang is not stable in Windows CI at the moment
@@ -35,30 +36,21 @@ function compute-projects-to-test() {
3536
;;
3637
clang)
3738
# lldb is temporarily removed to alleviate Linux pre-commit CI waiting times
38-
for p in clang clang-tools-extra compiler-rt cross-project-tests; do
39+
for p in clang-tools-extra compiler-rt cross-project-tests; do
3940
echo $p
4041
done
4142
;;
4243
clang-tools-extra)
43-
for p in clang-tools-extra libc; do
44-
echo $p
45-
done
44+
echo libc
4645
;;
4746
mlir)
48-
echo mlir
49-
# Flang is not stable in Windows CI at the moment
50-
if [[ $isForWindows == 0 ]]; then
51-
echo flang
52-
fi
53-
;;
54-
flang-rt)
5547
# Flang is not stable in Windows CI at the moment
5648
if [[ $isForWindows == 0 ]]; then
5749
echo flang
5850
fi
5951
;;
6052
*)
61-
echo "${project}"
53+
# Nothing to do
6254
;;
6355
esac
6456
done
@@ -73,11 +65,6 @@ function compute-runtimes-to-test() {
7365
echo $p
7466
done
7567
;;
76-
flang)
77-
for p in flang-rt; do
78-
echo $p
79-
done
80-
;;
8168
*)
8269
# Nothing to do
8370
;;

.ci/generate-buildkite-pipeline-premerge

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fi
7373
# needs while letting them run on the infrastructure provided by LLVM.
7474

7575
# Figure out which projects need to be built on each platform
76-
all_projects="bolt clang clang-tools-extra compiler-rt cross-project-tests flang flang-rt libc libclc lld lldb llvm mlir openmp polly pstl"
76+
all_projects="bolt clang clang-tools-extra compiler-rt cross-project-tests flang libc libclc lld lldb llvm mlir openmp polly pstl"
7777
modified_projects="$(keep-modified-projects ${all_projects})"
7878

7979
linux_projects_to_test=$(exclude-linux $(compute-projects-to-test 0 ${modified_projects}))

.ci/metrics/metrics.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
# This means we essentially have a list of workflows sorted by creation date,
4444
# and that's all we can deduce from it. So for each iteration, we'll blindly
4545
# process the last N workflows.
46-
GITHUB_WORKFLOWS_MAX_PROCESS_COUNT = 1000
46+
GITHUB_WORKFLOWS_MAX_PROCESS_COUNT = 2000
4747
# Second reason for the cut: reaching a workflow older than X.
4848
# This means we will miss long-tails (exceptional jobs running for more than
4949
# X hours), but that's also the case with the count cutoff above.
@@ -215,25 +215,14 @@ def buildkite_get_metrics(
215215
if job["name"] not in BUILDKITE_WORKFLOW_TO_TRACK:
216216
continue
217217

218+
# Don't count canceled jobs.
219+
if job["canceled_at"]:
220+
continue
221+
218222
created_at = dateutil.parser.isoparse(job["created_at"])
219-
scheduled_at = (
220-
created_at
221-
if job["scheduled_at"] is None
222-
else dateutil.parser.isoparse(job["scheduled_at"])
223-
)
224-
started_at = (
225-
scheduled_at
226-
if job["started_at"] is None
227-
else dateutil.parser.isoparse(job["started_at"])
228-
)
229-
if job["canceled_at"] is None:
230-
finished_at = (
231-
started_at
232-
if job["finished_at"] is None
233-
else dateutil.parser.isoparse(job["finished_at"])
234-
)
235-
else:
236-
finished_at = dateutil.parser.isoparse(job["canceled_at"])
223+
scheduled_at = dateutil.parser.isoparse(job["scheduled_at"])
224+
started_at = dateutil.parser.isoparse(job["started_at"])
225+
finished_at = dateutil.parser.isoparse(job["finished_at"])
237226

238227
job_name = BUILDKITE_WORKFLOW_TO_TRACK[job["name"]]
239228
queue_time = (started_at - scheduled_at).seconds

.ci/monolithic-linux.sh

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
6565
-D CMAKE_CXX_FLAGS=-gmlt \
6666
-D LLVM_CCACHE_BUILD=ON \
6767
-D MLIR_ENABLE_BINDINGS_PYTHON=ON \
68-
-D FLANG_ENABLE_FLANG_RT=OFF \
6968
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}"
7069

7170
echo "--- ninja"
@@ -96,9 +95,6 @@ if [[ "${runtimes}" != "" ]]; then
9695
cmake -S "${MONOREPO_ROOT}/runtimes" -B "${RUNTIMES_BUILD_DIR}" -GNinja \
9796
-D CMAKE_C_COMPILER="${INSTALL_DIR}/bin/clang" \
9897
-D CMAKE_CXX_COMPILER="${INSTALL_DIR}/bin/clang++" \
99-
-D CMAKE_Fortran_COMPILER="${BUILD_DIR}/bin/flang" \
100-
-D CMAKE_Fortran_COMPILER_WORKS=ON \
101-
-D LLVM_BINARY_DIR="${BUILD_DIR}" \
10298
-D LLVM_ENABLE_RUNTIMES="${runtimes}" \
10399
-D LIBCXX_CXX_ABI=libcxxabi \
104100
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
@@ -117,9 +113,6 @@ if [[ "${runtimes}" != "" ]]; then
117113
cmake -S "${MONOREPO_ROOT}/runtimes" -B "${RUNTIMES_BUILD_DIR}" -GNinja \
118114
-D CMAKE_C_COMPILER="${INSTALL_DIR}/bin/clang" \
119115
-D CMAKE_CXX_COMPILER="${INSTALL_DIR}/bin/clang++" \
120-
-D CMAKE_Fortran_COMPILER="${BUILD_DIR}/bin/flang" \
121-
-D CMAKE_Fortran_COMPILER_WORKS=ON \
122-
-D LLVM_BINARY_DIR="${BUILD_DIR}" \
123116
-D LLVM_ENABLE_RUNTIMES="${runtimes}" \
124117
-D LIBCXX_CXX_ABI=libcxxabi \
125118
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
@@ -138,9 +131,6 @@ if [[ "${runtimes}" != "" ]]; then
138131
cmake -S "${MONOREPO_ROOT}/runtimes" -B "${RUNTIMES_BUILD_DIR}" -GNinja \
139132
-D CMAKE_C_COMPILER="${INSTALL_DIR}/bin/clang" \
140133
-D CMAKE_CXX_COMPILER="${INSTALL_DIR}/bin/clang++" \
141-
-D CMAKE_Fortran_COMPILER="${BUILD_DIR}/bin/flang" \
142-
-D CMAKE_Fortran_COMPILER_WORKS=ON \
143-
-D LLVM_BINARY_DIR="${BUILD_DIR}" \
144134
-D LLVM_ENABLE_RUNTIMES="${runtimes}" \
145135
-D LIBCXX_CXX_ABI=libcxxabi \
146136
-D CMAKE_BUILD_TYPE=RelWithDebInfo \

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
stage1:
3838
if: github.repository_owner == 'llvm'
3939
runs-on: libcxx-self-hosted-linux
40-
container: ghcr.io/llvm/libcxx-linux-builder:b319dfef21f6c7b0bc6a356d6b9f41a3b3b98ae9
40+
container: ghcr.io/llvm/libcxx-linux-builder:b6bb9dc5abd7c6452c13a53fa8949cb259db459b
4141
continue-on-error: false
4242
strategy:
4343
fail-fast: false
@@ -75,7 +75,7 @@ jobs:
7575
stage2:
7676
if: github.repository_owner == 'llvm'
7777
runs-on: libcxx-self-hosted-linux
78-
container: ghcr.io/llvm/libcxx-linux-builder:b319dfef21f6c7b0bc6a356d6b9f41a3b3b98ae9
78+
container: ghcr.io/llvm/libcxx-linux-builder:b6bb9dc5abd7c6452c13a53fa8949cb259db459b
7979
needs: [ stage1 ]
8080
continue-on-error: false
8181
strategy:
@@ -137,7 +137,7 @@ jobs:
137137
'generic-hardening-mode-fast',
138138
'generic-hardening-mode-fast-with-abi-breaks',
139139
'generic-merged',
140-
'generic-modules-lsv',
140+
'generic-modules-cxx17-lsv',
141141
'generic-no-exceptions',
142142
'generic-no-experimental',
143143
'generic-no-filesystem',
@@ -167,7 +167,7 @@ jobs:
167167
- config: 'generic-msan'
168168
machine: libcxx-self-hosted-linux
169169
runs-on: ${{ matrix.machine }}
170-
container: ghcr.io/llvm/libcxx-linux-builder:b319dfef21f6c7b0bc6a356d6b9f41a3b3b98ae9
170+
container: ghcr.io/llvm/libcxx-linux-builder:b6bb9dc5abd7c6452c13a53fa8949cb259db459b
171171
steps:
172172
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
173173
- name: ${{ matrix.config }}

bolt/include/bolt/Core/Relocation.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,16 @@ enum { R_X86_64_converted_reloc_bit = 0x80 };
3535
namespace bolt {
3636

3737
/// Relocation class.
38-
struct Relocation {
38+
class Relocation {
39+
public:
40+
Relocation(uint64_t Offset, MCSymbol *Symbol, uint32_t Type, uint64_t Addend,
41+
uint64_t Value)
42+
: Offset(Offset), Symbol(Symbol), Type(Type), Optional(false),
43+
Addend(Addend), Value(Value) {}
44+
45+
Relocation()
46+
: Offset(0), Symbol(0), Type(0), Optional(0), Addend(0), Value(0) {}
47+
3948
static Triple::ArchType Arch; /// set by BinaryContext ctor.
4049

4150
/// The offset of this relocation in the object it is contained in.
@@ -47,6 +56,11 @@ struct Relocation {
4756
/// Relocation type.
4857
uint32_t Type;
4958

59+
private:
60+
/// Relocations added by optimizations can be optional.
61+
bool Optional = false;
62+
63+
public:
5064
/// The offset from the \p Symbol base used to compute the final
5165
/// value of this relocation.
5266
uint64_t Addend;
@@ -58,6 +72,10 @@ struct Relocation {
5872
/// Return size in bytes of the given relocation \p Type.
5973
static size_t getSizeForType(uint32_t Type);
6074

75+
/// Some relocations added by optimizations are optional, meaning they can be
76+
/// omitted under certain circumstances.
77+
void setOptional() { Optional = true; }
78+
6179
/// Return size of this relocation.
6280
size_t getSize() const { return getSizeForType(Type); }
6381

bolt/include/bolt/Passes/NonPacProtectedRetAnalysis.h renamed to bolt/include/bolt/Passes/PAuthGadgetScanner.h

Lines changed: 43 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
//===- bolt/Passes/NonPacProtectedRetAnalysis.h -----------------*- C++ -*-===//
1+
//===- bolt/Passes/PAuthGadgetScanner.h -------------------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef BOLT_PASSES_NONPACPROTECTEDRETANALYSIS_H
10-
#define BOLT_PASSES_NONPACPROTECTEDRETANALYSIS_H
9+
#ifndef BOLT_PASSES_PAUTHGADGETSCANNER_H
10+
#define BOLT_PASSES_PAUTHGADGETSCANNER_H
1111

1212
#include "bolt/Core/BinaryContext.h"
1313
#include "bolt/Core/BinaryFunction.h"
@@ -173,63 +173,59 @@ struct MCInstReference {
173173

174174
raw_ostream &operator<<(raw_ostream &OS, const MCInstReference &);
175175

176-
struct GeneralDiagnostic {
177-
std::string Text;
178-
GeneralDiagnostic(const std::string &Text) : Text(Text) {}
179-
bool operator==(const GeneralDiagnostic &RHS) const {
180-
return Text == RHS.Text;
181-
}
176+
namespace PAuthGadgetScanner {
177+
178+
class PacRetAnalysis;
179+
struct State;
180+
181+
/// Description of a gadget kind that can be detected. Intended to be
182+
/// statically allocated to be attached to reports by reference.
183+
class GadgetKind {
184+
const char *Description;
185+
186+
public:
187+
GadgetKind(const char *Description) : Description(Description) {}
188+
189+
const StringRef getDescription() const { return Description; }
182190
};
183191

184-
raw_ostream &operator<<(raw_ostream &OS, const GeneralDiagnostic &Diag);
192+
/// Base report located at some instruction, without any additional information.
193+
struct Report {
194+
MCInstReference Location;
195+
196+
Report(MCInstReference Location) : Location(Location) {}
197+
virtual ~Report() {}
185198

186-
namespace NonPacProtectedRetAnalysis {
187-
struct Annotation {
188-
MCInstReference RetInst;
189-
Annotation(MCInstReference RetInst) : RetInst(RetInst) {}
190-
virtual bool operator==(const Annotation &RHS) const {
191-
return RetInst == RHS.RetInst;
192-
}
193-
Annotation &operator=(const Annotation &Other) {
194-
if (this == &Other)
195-
return *this;
196-
RetInst = Other.RetInst;
197-
return *this;
198-
}
199-
virtual ~Annotation() {}
200199
virtual void generateReport(raw_ostream &OS,
201200
const BinaryContext &BC) const = 0;
201+
202+
void printBasicInfo(raw_ostream &OS, const BinaryContext &BC,
203+
StringRef IssueKind) const;
202204
};
203205

204-
struct Gadget : public Annotation {
205-
std::vector<MCInstReference> OverwritingRetRegInst;
206-
virtual bool operator==(const Gadget &RHS) const {
207-
return Annotation::operator==(RHS) &&
208-
OverwritingRetRegInst == RHS.OverwritingRetRegInst;
209-
}
210-
Gadget(MCInstReference RetInst,
211-
const std::vector<MCInstReference> &OverwritingRetRegInst)
212-
: Annotation(RetInst), OverwritingRetRegInst(OverwritingRetRegInst) {}
213-
virtual void generateReport(raw_ostream &OS,
214-
const BinaryContext &BC) const override;
206+
struct GadgetReport : public Report {
207+
const GadgetKind &Kind;
208+
std::vector<MCInstReference> OverwritingInstrs;
209+
210+
GadgetReport(const GadgetKind &Kind, MCInstReference Location,
211+
std::vector<MCInstReference> OverwritingInstrs)
212+
: Report(Location), Kind(Kind), OverwritingInstrs(OverwritingInstrs) {}
213+
214+
void generateReport(raw_ostream &OS, const BinaryContext &BC) const override;
215215
};
216216

217-
struct GenDiag : public Annotation {
218-
GeneralDiagnostic Diag;
219-
virtual bool operator==(const GenDiag &RHS) const {
220-
return Annotation::operator==(RHS) && Diag == RHS.Diag;
221-
}
222-
GenDiag(MCInstReference RetInst, const std::string &Text)
223-
: Annotation(RetInst), Diag(Text) {}
217+
/// Report with a free-form message attached.
218+
struct GenericReport : public Report {
219+
std::string Text;
220+
GenericReport(MCInstReference Location, const std::string &Text)
221+
: Report(Location), Text(Text) {}
224222
virtual void generateReport(raw_ostream &OS,
225223
const BinaryContext &BC) const override;
226224
};
227225

228-
class PacRetAnalysis;
229-
230226
struct FunctionAnalysisResult {
231227
SmallSet<MCPhysReg, 1> RegistersAffected;
232-
std::vector<std::shared_ptr<Annotation>> Diagnostics;
228+
std::vector<std::shared_ptr<Report>> Diagnostics;
233229
};
234230

235231
class Analysis : public BinaryFunctionPass {
@@ -245,13 +241,13 @@ class Analysis : public BinaryFunctionPass {
245241
public:
246242
explicit Analysis() : BinaryFunctionPass(false) {}
247243

248-
const char *getName() const override { return "non-pac-protected-rets"; }
244+
const char *getName() const override { return "pauth-gadget-scanner"; }
249245

250246
/// Pass entry point
251247
Error runOnFunctions(BinaryContext &BC) override;
252248
};
253249

254-
} // namespace NonPacProtectedRetAnalysis
250+
} // namespace PAuthGadgetScanner
255251
} // namespace bolt
256252
} // namespace llvm
257253

bolt/include/bolt/Utils/CommandLineOpts.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ extern llvm::cl::opt<unsigned> BucketsPerLine;
3737
extern llvm::cl::opt<bool> DiffOnly;
3838
extern llvm::cl::opt<bool> EnableBAT;
3939
extern llvm::cl::opt<bool> EqualizeBBCounts;
40+
extern llvm::cl::opt<bool> ForcePatch;
4041
extern llvm::cl::opt<bool> RemoveSymtab;
4142
extern llvm::cl::opt<unsigned> ExecutionCountThreshold;
4243
extern llvm::cl::opt<unsigned> HeatmapBlock;

bolt/lib/Passes/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ add_llvm_library(LLVMBOLTPasses
2323
LoopInversionPass.cpp
2424
LivenessAnalysis.cpp
2525
MCF.cpp
26-
NonPacProtectedRetAnalysis.cpp
2726
PatchEntries.cpp
27+
PAuthGadgetScanner.cpp
2828
PettisAndHansen.cpp
2929
PLTCall.cpp
3030
ProfileQualityStats.cpp

0 commit comments

Comments
 (0)