Skip to content

Commit 2d77d4f

Browse files
authored
Merge branch 'main' into vector-peephole/fold-vmerge-to-mask
2 parents 8f566c4 + a05393a commit 2d77d4f

File tree

2,537 files changed

+109476
-44520
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,537 files changed

+109476
-44520
lines changed

.github/new-prs-labeler.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,10 @@ backend:NVPTX:
777777
- 'llvm/**/*nvptx*/**'
778778
- 'llvm/**/*NVPTX*/**'
779779

780+
backend:MIPS:
781+
- '**/*mips*'
782+
- '**/*Mips*'
783+
780784
backend:RISC-V:
781785
- clang/**/*riscv*
782786
- clang/**/*RISCV*

.github/workflows/libcxx-restart-preempted-jobs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
with:
3434
script: |
3535
const failure_regex = /Process completed with exit code 1./
36-
const preemption_regex = /The runner has received a shutdown signal/
36+
const preemption_regex = /(The runner has received a shutdown signal)|(The operation was canceled)/
3737
3838
const wf_run = context.payload.workflow_run
3939
core.notice(`Running on "${wf_run.display_title}" by @${wf_run.actor.login} (event: ${wf_run.event})\nWorkflow run URL: ${wf_run.html_url}`)

bolt/include/bolt/Passes/PAuthGadgetScanner.h

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ namespace PAuthGadgetScanner {
199199
// to distinguish intermediate and final results at the type level.
200200
//
201201
// Here is an overview of issue life-cycle:
202-
// * an analysis (SrcSafetyAnalysis at now, DstSafetyAnalysis will be added
203-
// later to support the detection of authentication oracles) computes register
202+
// * an analysis (SrcSafetyAnalysis or DstSafetyAnalysis) computes register
204203
// state for each instruction in the function.
205204
// * for each instruction, it is checked whether it is a gadget of some kind,
206205
// taking the computed state into account. If a gadget is found, its kind
@@ -273,6 +272,11 @@ class ExtraInfo {
273272
virtual ~ExtraInfo() {}
274273
};
275274

275+
/// The set of instructions writing to the affected register in an unsafe
276+
/// manner.
277+
///
278+
/// This is a hint to be printed alongside the report. It should be further
279+
/// analyzed by the user.
276280
class ClobberingInfo : public ExtraInfo {
277281
SmallVector<MCInstReference> ClobberingInstrs;
278282

@@ -282,6 +286,20 @@ class ClobberingInfo : public ExtraInfo {
282286
void print(raw_ostream &OS, const MCInstReference Location) const override;
283287
};
284288

289+
/// The set of instructions leaking the authenticated pointer before the
290+
/// result of authentication was checked.
291+
///
292+
/// This is a hint to be printed alongside the report. It should be further
293+
/// analyzed by the user.
294+
class LeakageInfo : public ExtraInfo {
295+
SmallVector<MCInstReference> LeakingInstrs;
296+
297+
public:
298+
LeakageInfo(ArrayRef<MCInstReference> Instrs) : LeakingInstrs(Instrs) {}
299+
300+
void print(raw_ostream &OS, const MCInstReference Location) const override;
301+
};
302+
285303
/// A brief version of a report that can be further augmented with the details.
286304
///
287305
/// A half-baked report produced on the first run of the analysis. An extra,
@@ -322,6 +340,9 @@ class FunctionAnalysisContext {
322340
void findUnsafeUses(SmallVector<PartialReport<MCPhysReg>> &Reports);
323341
void augmentUnsafeUseReports(ArrayRef<PartialReport<MCPhysReg>> Reports);
324342

343+
void findUnsafeDefs(SmallVector<PartialReport<MCPhysReg>> &Reports);
344+
void augmentUnsafeDefReports(ArrayRef<PartialReport<MCPhysReg>> Reports);
345+
325346
/// Process the reports which do not have to be augmented, and remove them
326347
/// from Reports.
327348
void handleSimpleReports(SmallVector<PartialReport<MCPhysReg>> &Reports);

bolt/include/bolt/Profile/DataAggregator.h

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,24 +99,28 @@ class DataAggregator : public DataReader {
9999
uint64_t Addr;
100100
};
101101

102+
/// Container for the unit of branch data.
103+
/// Backwards compatible with legacy use for branches and fall-throughs:
104+
/// - if \p Branch is FT_ONLY or FT_EXTERNAL_ORIGIN, the trace only
105+
/// contains fall-through data,
106+
/// - if \p To is BR_ONLY, the trace only contains branch data.
102107
struct Trace {
108+
static constexpr const uint64_t EXTERNAL = 0ULL;
109+
static constexpr const uint64_t BR_ONLY = -1ULL;
110+
static constexpr const uint64_t FT_ONLY = -1ULL;
111+
static constexpr const uint64_t FT_EXTERNAL_ORIGIN = -2ULL;
112+
113+
uint64_t Branch;
103114
uint64_t From;
104115
uint64_t To;
105-
Trace(uint64_t From, uint64_t To) : From(From), To(To) {}
106-
bool operator==(const Trace &Other) const {
107-
return From == Other.From && To == Other.To;
108-
}
116+
auto tie() const { return std::tie(Branch, From, To); }
117+
bool operator==(const Trace &Other) const { return tie() == Other.tie(); }
118+
bool operator<(const Trace &Other) const { return tie() < Other.tie(); }
109119
};
120+
friend raw_ostream &operator<<(raw_ostream &OS, const Trace &);
110121

111122
struct TraceHash {
112-
size_t operator()(const Trace &L) const {
113-
return std::hash<uint64_t>()(L.From << 32 | L.To);
114-
}
115-
};
116-
117-
struct FTInfo {
118-
uint64_t InternCount{0};
119-
uint64_t ExternCount{0};
123+
size_t operator()(const Trace &L) const { return hash_combine(L.tie()); }
120124
};
121125

122126
struct TakenBranchInfo {
@@ -126,8 +130,11 @@ class DataAggregator : public DataReader {
126130

127131
/// Intermediate storage for profile data. We save the results of parsing
128132
/// and use them later for processing and assigning profile.
129-
std::unordered_map<Trace, TakenBranchInfo, TraceHash> BranchLBRs;
130-
std::unordered_map<Trace, FTInfo, TraceHash> FallthroughLBRs;
133+
std::unordered_map<Trace, TakenBranchInfo, TraceHash> TraceMap;
134+
std::vector<std::pair<Trace, TakenBranchInfo>> Traces;
135+
/// Pre-populated addresses of returns, coming from pre-aggregated data or
136+
/// disassembly. Used to disambiguate call-continuation fall-throughs.
137+
std::unordered_set<uint64_t> Returns;
131138
std::unordered_map<uint64_t, uint64_t> BasicSamples;
132139
std::vector<PerfMemSample> MemSamples;
133140

@@ -200,8 +207,8 @@ class DataAggregator : public DataReader {
200207
/// Return a vector of offsets corresponding to a trace in a function
201208
/// if the trace is valid, std::nullopt otherwise.
202209
std::optional<SmallVector<std::pair<uint64_t, uint64_t>, 16>>
203-
getFallthroughsInTrace(BinaryFunction &BF, const LBREntry &First,
204-
const LBREntry &Second, uint64_t Count = 1) const;
210+
getFallthroughsInTrace(BinaryFunction &BF, const Trace &Trace, uint64_t Count,
211+
bool IsReturn) const;
205212

206213
/// Record external entry into the function \p BF.
207214
///
@@ -261,12 +268,14 @@ class DataAggregator : public DataReader {
261268
uint64_t From, uint64_t To, uint64_t Count,
262269
uint64_t Mispreds);
263270

271+
/// Checks if \p Addr corresponds to a return instruction.
272+
bool checkReturn(uint64_t Addr);
273+
264274
/// Register a \p Branch.
265275
bool doBranch(uint64_t From, uint64_t To, uint64_t Count, uint64_t Mispreds);
266276

267277
/// Register a trace between two LBR entries supplied in execution order.
268-
bool doTrace(const LBREntry &First, const LBREntry &Second,
269-
uint64_t Count = 1);
278+
bool doTrace(const Trace &Trace, uint64_t Count, bool IsReturn);
270279

271280
/// Parser helpers
272281
/// Return false if we exhausted our parser buffer and finished parsing
@@ -516,6 +525,21 @@ inline raw_ostream &operator<<(raw_ostream &OS,
516525
OS << formatv("{0:x} -> {1:x}/{2}", L.From, L.To, L.Mispred ? 'M' : 'P');
517526
return OS;
518527
}
528+
529+
inline raw_ostream &operator<<(raw_ostream &OS,
530+
const DataAggregator::Trace &T) {
531+
switch (T.Branch) {
532+
case DataAggregator::Trace::FT_ONLY:
533+
case DataAggregator::Trace::FT_EXTERNAL_ORIGIN:
534+
break;
535+
default:
536+
OS << Twine::utohexstr(T.Branch) << " -> ";
537+
}
538+
OS << Twine::utohexstr(T.From);
539+
if (T.To != DataAggregator::Trace::BR_ONLY)
540+
OS << " ... " << Twine::utohexstr(T.To);
541+
return OS;
542+
}
519543
} // namespace bolt
520544
} // namespace llvm
521545

0 commit comments

Comments
 (0)