Skip to content

Commit e6bece8

Browse files
committed
merge main into amd-staging
2 parents 42ce4c6 + 387f3e8 commit e6bece8

File tree

546 files changed

+12204
-6155
lines changed

Some content is hidden

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

546 files changed

+12204
-6155
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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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',

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/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)