Skip to content

Commit 315de55

Browse files
committed
Merge remote-tracking branch 'origin/main' into vplan-narrow-interleave
2 parents 86ac70a + 2f2100c commit 315de55

File tree

804 files changed

+34562
-43077
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

804 files changed

+34562
-43077
lines changed

.ci/metrics/metrics.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -90,23 +90,6 @@ if [[ "${runtimes}" != "" ]]; then
9090
INSTALL_DIR="${BUILD_DIR}/install"
9191
mkdir -p ${RUNTIMES_BUILD_DIR}
9292

93-
echo "--- cmake runtimes C++03"
94-
95-
cmake -S "${MONOREPO_ROOT}/runtimes" -B "${RUNTIMES_BUILD_DIR}" -GNinja \
96-
-D CMAKE_C_COMPILER="${INSTALL_DIR}/bin/clang" \
97-
-D CMAKE_CXX_COMPILER="${INSTALL_DIR}/bin/clang++" \
98-
-D LLVM_ENABLE_RUNTIMES="${runtimes}" \
99-
-D LIBCXX_CXX_ABI=libcxxabi \
100-
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
101-
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
102-
-D LIBCXX_TEST_PARAMS="std=c++03" \
103-
-D LIBCXXABI_TEST_PARAMS="std=c++03" \
104-
-D LLVM_LIT_ARGS="${lit_args}"
105-
106-
echo "--- ninja runtimes C++03"
107-
108-
ninja -vC "${RUNTIMES_BUILD_DIR}" ${runtime_targets}
109-
11093
echo "--- cmake runtimes C++26"
11194

11295
rm -rf "${RUNTIMES_BUILD_DIR}"
@@ -140,6 +123,6 @@ if [[ "${runtimes}" != "" ]]; then
140123
-D LLVM_LIT_ARGS="${lit_args}"
141124

142125
echo "--- ninja runtimes clang modules"
143-
126+
144127
ninja -vC "${RUNTIMES_BUILD_DIR}" ${runtime_targets}
145128
fi

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ jobs:
2727
# The arch names should match the names used on dockerhub.
2828
# See https://github.com/docker-library/official-images#architectures-other-than-amd64
2929
- arch: amd64
30-
runs-on: depot-ubuntu-22.04-16
30+
runs-on: depot-ubuntu-24.04-16
3131
- arch: arm64v8
32-
runs-on: depot-ubuntu-22.04-arm-16
32+
runs-on: depot-ubuntu-24.04-arm-16
3333
steps:
3434
- name: Checkout LLVM
3535
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

.github/workflows/commit-access-greeter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
if: >-
1616
github.repository_owner == 'llvm' &&
1717
github.event.label.name == 'infra:commit-access-request'
18-
runs-on: ubuntu-22.04
18+
runs-on: ubuntu-24.04
1919
steps:
2020
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
2121
with:

.github/workflows/commit-access-review.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ permissions:
1212
jobs:
1313
commit-access-review:
1414
if: github.repository_owner == 'llvm'
15-
runs-on: ubuntu-22.04
15+
runs-on: ubuntu-24.04
1616
steps:
1717
- name: Fetch LLVM sources
1818
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

.github/workflows/issue-write.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939

4040
- name: 'Comment on PR'
4141
if: steps.download-artifact.outputs.artifact-id != ''
42-
uses: actions/github-script@ffc2c79a5b2490bd33e0a41c1de74b877714d736 # v3.2.0
42+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
4343
with:
4444
github-token: ${{ secrets.GITHUB_TOKEN }}
4545
script: |
@@ -49,7 +49,7 @@ jobs:
4949
return;
5050
}
5151
52-
let runInfo = await github.actions.getWorkflowRun({
52+
let runInfo = await github.rest.actions.getWorkflowRun({
5353
owner: context.repo.owner,
5454
repo: context.repo.repo,
5555
run_id: context.payload.workflow_run.id
@@ -122,7 +122,7 @@ jobs:
122122
// Security check: Ensure that this comment was created by
123123
// the github-actions bot, so a malicious input won't overwrite
124124
// a user's comment.
125-
github.issues.getComment({
125+
github.rest.issues.getComment({
126126
owner: context.repo.owner,
127127
repo: context.repo.repo,
128128
comment_id: comment.id
@@ -132,7 +132,7 @@ jobs:
132132
console.log("Invalid comment id: " + comment.id);
133133
return;
134134
}
135-
github.issues.updateComment({
135+
github.rest.issues.updateComment({
136136
owner: context.repo.owner,
137137
repo: context.repo.repo,
138138
issue_number: pr_number,
@@ -141,7 +141,7 @@ jobs:
141141
});
142142
});
143143
} else {
144-
github.issues.createComment({
144+
github.rest.issues.createComment({
145145
owner: context.repo.owner,
146146
repo: context.repo.repo,
147147
issue_number: pr_number,

.github/workflows/release-asset-audit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ permissions:
1919
jobs:
2020
audit:
2121
name: "Release Asset Audit"
22-
runs-on: ubuntu-22.04
22+
runs-on: ubuntu-24.04
2323
if: github.repository == 'llvm/llvm-project'
2424
steps:
2525
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 #v4.1.6

.github/workflows/release-binaries-all.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
setup-variables:
5858
if: >-
5959
(github.event_name != 'pull_request' || github.event.action != 'closed')
60-
runs-on: ubuntu-22.04
60+
runs-on: ubuntu-24.04
6161
outputs:
6262
release-version: ${{ steps.vars.outputs.release-version }}
6363
upload: ${{ steps.vars.outputs.upload }}
@@ -85,6 +85,8 @@ jobs:
8585
strategy:
8686
fail-fast: false
8787
matrix:
88+
# We use ubuntu-22.04 rather than the latest version to make the built
89+
# binaries more portable (eg functional aginast older glibc).
8890
runs-on:
8991
- ubuntu-22.04
9092
- ubuntu-22.04-arm

.github/workflows/release-binaries.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ on:
1616
description: "Runner to use for the build"
1717
required: true
1818
type: choice
19+
# We use ubuntu-22.04 rather than the latest version to make the built
20+
# binaries more portable (eg functional aginast older glibc).
1921
options:
2022
- ubuntu-22.04
2123
- ubuntu-22.04-arm
@@ -276,7 +278,7 @@ jobs:
276278
if: >-
277279
github.event_name != 'pull_request' &&
278280
needs.prepare.outputs.upload == 'true'
279-
runs-on: ubuntu-22.04
281+
runs-on: ubuntu-24.04
280282
permissions:
281283
contents: write # For release uploads
282284
id-token: write # For artifact attestations

.github/workflows/scorecard.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ jobs:
3131

3232
steps:
3333
- name: "Checkout code"
34-
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
34+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3535
with:
3636
persist-credentials: false
3737

3838
- name: "Run analysis"
39-
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
39+
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
4040
with:
4141
results_file: results.sarif
4242
results_format: sarif
@@ -49,14 +49,14 @@ jobs:
4949
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
5050
# format to the repository Actions tab.
5151
- name: "Upload artifact"
52-
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
52+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
5353
with:
5454
name: SARIF file
5555
path: results.sarif
5656
retention-days: 5
5757

5858
# Upload the results to GitHub's code scanning dashboard.
5959
- name: "Upload to code-scanning"
60-
uses: github/codeql-action/upload-sarif@17573ee1cc1b9d061760f3a006fc4aac4f944fd5 # v2.2.4
60+
uses: github/codeql-action/upload-sarif@80f993039571a6de66594ecaa432875a6942e8e0 # v2.20.6
6161
with:
6262
sarif_file: results.sarif

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

Lines changed: 69 additions & 50 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,85 +173,104 @@ 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+
// The two methods below are called by Analysis::computeDetailedInfo when
203+
// iterating over the reports.
204+
virtual const ArrayRef<MCPhysReg> getAffectedRegisters() const { return {}; }
205+
virtual void setOverwritingInstrs(const ArrayRef<MCInstReference> Instrs) {}
206+
207+
void printBasicInfo(raw_ostream &OS, const BinaryContext &BC,
208+
StringRef IssueKind) const;
202209
};
203210

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;
211+
struct GadgetReport : public Report {
212+
// The particular kind of gadget that is detected.
213+
const GadgetKind &Kind;
214+
// The set of registers related to this gadget report (possibly empty).
215+
SmallVector<MCPhysReg> AffectedRegisters;
216+
// The instructions that clobber the affected registers.
217+
// There is no one-to-one correspondence with AffectedRegisters: for example,
218+
// the same register can be overwritten by different instructions in different
219+
// preceding basic blocks.
220+
SmallVector<MCInstReference> OverwritingInstrs;
221+
222+
GadgetReport(const GadgetKind &Kind, MCInstReference Location,
223+
const BitVector &AffectedRegisters)
224+
: Report(Location), Kind(Kind),
225+
AffectedRegisters(AffectedRegisters.set_bits()) {}
226+
227+
void generateReport(raw_ostream &OS, const BinaryContext &BC) const override;
228+
229+
const ArrayRef<MCPhysReg> getAffectedRegisters() const override {
230+
return AffectedRegisters;
209231
}
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;
215-
};
216232

217-
struct GenDiag : public Annotation {
218-
GeneralDiagnostic Diag;
219-
virtual bool operator==(const GenDiag &RHS) const {
220-
return Annotation::operator==(RHS) && Diag == RHS.Diag;
233+
void setOverwritingInstrs(const ArrayRef<MCInstReference> Instrs) override {
234+
OverwritingInstrs.assign(Instrs.begin(), Instrs.end());
221235
}
222-
GenDiag(MCInstReference RetInst, const std::string &Text)
223-
: Annotation(RetInst), Diag(Text) {}
236+
};
237+
238+
/// Report with a free-form message attached.
239+
struct GenericReport : public Report {
240+
std::string Text;
241+
GenericReport(MCInstReference Location, const std::string &Text)
242+
: Report(Location), Text(Text) {}
224243
virtual void generateReport(raw_ostream &OS,
225244
const BinaryContext &BC) const override;
226245
};
227246

228-
class PacRetAnalysis;
229-
230247
struct FunctionAnalysisResult {
231-
SmallSet<MCPhysReg, 1> RegistersAffected;
232-
std::vector<std::shared_ptr<Annotation>> Diagnostics;
248+
std::vector<std::shared_ptr<Report>> Diagnostics;
233249
};
234250

235251
class Analysis : public BinaryFunctionPass {
236252
void runOnFunction(BinaryFunction &Function,
237253
MCPlusBuilder::AllocatorIdTy AllocatorId);
238-
FunctionAnalysisResult
239-
computeDfState(PacRetAnalysis &PRA, BinaryFunction &BF,
240-
MCPlusBuilder::AllocatorIdTy AllocatorId);
254+
FunctionAnalysisResult findGadgets(BinaryFunction &BF,
255+
MCPlusBuilder::AllocatorIdTy AllocatorId);
256+
257+
void computeDetailedInfo(BinaryFunction &BF,
258+
MCPlusBuilder::AllocatorIdTy AllocatorId,
259+
FunctionAnalysisResult &Result);
241260

242261
std::map<const BinaryFunction *, FunctionAnalysisResult> AnalysisResults;
243262
std::mutex AnalysisResultsMutex;
244263

245264
public:
246265
explicit Analysis() : BinaryFunctionPass(false) {}
247266

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

250269
/// Pass entry point
251270
Error runOnFunctions(BinaryContext &BC) override;
252271
};
253272

254-
} // namespace NonPacProtectedRetAnalysis
273+
} // namespace PAuthGadgetScanner
255274
} // namespace bolt
256275
} // namespace llvm
257276

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;

0 commit comments

Comments
 (0)