Skip to content

Commit 2d1e0ad

Browse files
committed
New pass to deduplicate blocks
1 parent 1e86570 commit 2d1e0ad

File tree

14 files changed

+422
-37
lines changed

14 files changed

+422
-37
lines changed

compiler/rustc_ast/src/ast.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1979,7 +1979,7 @@ bitflags::bitflags! {
19791979
}
19801980
}
19811981

1982-
#[derive(Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
1982+
#[derive(Clone, PartialEq, PartialOrd, Encodable, Decodable, Debug, Hash, HashStable_Generic)]
19831983
pub enum InlineAsmTemplatePiece {
19841984
String(String),
19851985
Placeholder { operand_idx: usize, modifier: Option<char>, span: Span },
@@ -2067,7 +2067,7 @@ pub struct InlineAsm {
20672067
/// Inline assembly dialect.
20682068
///
20692069
/// E.g., `"intel"` as in `llvm_asm!("mov eax, 2" : "={eax}"(result) : : : "intel")`.
2070-
#[derive(Clone, PartialEq, Encodable, Decodable, Debug, Copy, HashStable_Generic)]
2070+
#[derive(Clone, PartialEq, Encodable, Decodable, Debug, Copy, Hash, HashStable_Generic)]
20712071
pub enum LlvmAsmDialect {
20722072
Att,
20732073
Intel,

compiler/rustc_hir/src/hir.rs

+26-4
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,18 @@ impl Body<'hir> {
12811281
}
12821282

12831283
/// The type of source expression that caused this generator to be created.
1284-
#[derive(Clone, PartialEq, Eq, Hash, HashStable_Generic, Encodable, Decodable, Debug, Copy)]
1284+
#[derive(
1285+
Clone,
1286+
PartialEq,
1287+
PartialOrd,
1288+
Eq,
1289+
Hash,
1290+
HashStable_Generic,
1291+
Encodable,
1292+
Decodable,
1293+
Debug,
1294+
Copy
1295+
)]
12851296
pub enum GeneratorKind {
12861297
/// An explicit `async` block or the body of an async function.
12871298
Async(AsyncGeneratorKind),
@@ -1313,7 +1324,18 @@ impl GeneratorKind {
13131324
///
13141325
/// This helps error messages but is also used to drive coercions in
13151326
/// type-checking (see #60424).
1316-
#[derive(Clone, PartialEq, Eq, Hash, HashStable_Generic, Encodable, Decodable, Debug, Copy)]
1327+
#[derive(
1328+
Clone,
1329+
PartialEq,
1330+
PartialOrd,
1331+
Eq,
1332+
Hash,
1333+
HashStable_Generic,
1334+
Encodable,
1335+
Decodable,
1336+
Debug,
1337+
Copy
1338+
)]
13171339
pub enum AsyncGeneratorKind {
13181340
/// An explicit `async` block written by the user.
13191341
Block,
@@ -2308,7 +2330,7 @@ pub struct InlineAsm<'hir> {
23082330
pub line_spans: &'hir [Span],
23092331
}
23102332

2311-
#[derive(Copy, Clone, Encodable, Decodable, Debug, HashStable_Generic, PartialEq)]
2333+
#[derive(Copy, Clone, Encodable, Decodable, Debug, Hash, HashStable_Generic, PartialEq)]
23122334
pub struct LlvmInlineAsmOutput {
23132335
pub constraint: Symbol,
23142336
pub is_rw: bool,
@@ -2319,7 +2341,7 @@ pub struct LlvmInlineAsmOutput {
23192341
// NOTE(eddyb) This is used within MIR as well, so unlike the rest of the HIR,
23202342
// it needs to be `Clone` and `Decodable` and use plain `Vec<T>` instead of
23212343
// arena-allocated slice.
2322-
#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic, PartialEq)]
2344+
#[derive(Clone, Encodable, Decodable, Debug, Hash, HashStable_Generic, PartialEq)]
23232345
pub struct LlvmInlineAsmInner {
23242346
pub asm: Symbol,
23252347
pub asm_str_style: StrStyle,

compiler/rustc_middle/src/mir/coverage.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl From<InjectedExpressionId> for ExpressionOperandId {
9292
}
9393
}
9494

95-
#[derive(Clone, PartialEq, TyEncodable, TyDecodable, HashStable, TypeFoldable)]
95+
#[derive(Clone, PartialEq, TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable)]
9696
pub enum CoverageKind {
9797
Counter {
9898
function_source_hash: u64,
@@ -148,7 +148,18 @@ impl Debug for CoverageKind {
148148
}
149149
}
150150

151-
#[derive(Clone, TyEncodable, TyDecodable, HashStable, TypeFoldable, PartialEq, Eq, PartialOrd, Ord)]
151+
#[derive(
152+
Clone,
153+
TyEncodable,
154+
TyDecodable,
155+
Hash,
156+
HashStable,
157+
TypeFoldable,
158+
PartialEq,
159+
Eq,
160+
PartialOrd,
161+
Ord
162+
)]
152163
pub struct CodeRegion {
153164
pub file_name: Symbol,
154165
pub start_line: u32,
@@ -167,7 +178,7 @@ impl Debug for CodeRegion {
167178
}
168179
}
169180

170-
#[derive(Copy, Clone, Debug, PartialEq, TyEncodable, TyDecodable, HashStable, TypeFoldable)]
181+
#[derive(Copy, Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable)]
171182
pub enum Op {
172183
Subtract,
173184
Add,

compiler/rustc_middle/src/mir/mod.rs

+27-17
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ impl SourceInfo {
594594
// Borrow kinds
595595

596596
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, TyEncodable, TyDecodable)]
597-
#[derive(HashStable)]
597+
#[derive(Hash, HashStable)]
598598
pub enum BorrowKind {
599599
/// Data must be immutable and is aliasable.
600600
Shared,
@@ -1163,7 +1163,7 @@ pub struct BasicBlockData<'tcx> {
11631163
}
11641164

11651165
/// Information about an assertion failure.
1166-
#[derive(Clone, TyEncodable, TyDecodable, HashStable, PartialEq)]
1166+
#[derive(Clone, TyEncodable, TyDecodable, Hash, HashStable, PartialEq, PartialOrd)]
11671167
pub enum AssertKind<O> {
11681168
BoundsCheck { len: O, index: O },
11691169
Overflow(BinOp, O, O),
@@ -1174,7 +1174,17 @@ pub enum AssertKind<O> {
11741174
ResumedAfterPanic(GeneratorKind),
11751175
}
11761176

1177-
#[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, HashStable, TypeFoldable)]
1177+
#[derive(
1178+
Clone,
1179+
Debug,
1180+
PartialEq,
1181+
PartialOrd,
1182+
TyEncodable,
1183+
TyDecodable,
1184+
Hash,
1185+
HashStable,
1186+
TypeFoldable
1187+
)]
11781188
pub enum InlineAsmOperand<'tcx> {
11791189
In {
11801190
reg: InlineAsmRegOrRegClass,
@@ -1449,7 +1459,7 @@ impl Statement<'_> {
14491459
}
14501460
}
14511461

1452-
#[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, HashStable, TypeFoldable)]
1462+
#[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable)]
14531463
pub enum StatementKind<'tcx> {
14541464
/// Write the RHS Rvalue to the LHS Place.
14551465
Assign(Box<(Place<'tcx>, Rvalue<'tcx>)>),
@@ -1517,7 +1527,7 @@ impl<'tcx> StatementKind<'tcx> {
15171527
}
15181528

15191529
/// Describes what kind of retag is to be performed.
1520-
#[derive(Copy, Clone, TyEncodable, TyDecodable, Debug, PartialEq, Eq, HashStable)]
1530+
#[derive(Copy, Clone, TyEncodable, TyDecodable, Debug, PartialEq, Eq, Hash, HashStable)]
15211531
pub enum RetagKind {
15221532
/// The initial retag when entering a function.
15231533
FnEntry,
@@ -1530,7 +1540,7 @@ pub enum RetagKind {
15301540
}
15311541

15321542
/// The `FakeReadCause` describes the type of pattern why a FakeRead statement exists.
1533-
#[derive(Copy, Clone, TyEncodable, TyDecodable, Debug, HashStable, PartialEq)]
1543+
#[derive(Copy, Clone, TyEncodable, TyDecodable, Debug, Hash, HashStable, PartialEq)]
15341544
pub enum FakeReadCause {
15351545
/// Inject a fake read of the borrowed input at the end of each guards
15361546
/// code.
@@ -1572,7 +1582,7 @@ pub enum FakeReadCause {
15721582
ForIndex,
15731583
}
15741584

1575-
#[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, HashStable, TypeFoldable)]
1585+
#[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable)]
15761586
pub struct LlvmInlineAsm<'tcx> {
15771587
pub asm: hir::LlvmInlineAsmInner,
15781588
pub outputs: Box<[Place<'tcx>]>,
@@ -1619,7 +1629,7 @@ impl Debug for Statement<'_> {
16191629
}
16201630
}
16211631

1622-
#[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, HashStable, TypeFoldable)]
1632+
#[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable)]
16231633
pub struct Coverage {
16241634
pub kind: CoverageKind,
16251635
pub code_region: Option<CodeRegion>,
@@ -1915,7 +1925,7 @@ pub struct SourceScopeLocalData {
19151925

19161926
/// These are values that can appear inside an rvalue. They are intentionally
19171927
/// limited to prevent rvalues from being nested in one another.
1918-
#[derive(Clone, PartialEq, TyEncodable, TyDecodable, HashStable)]
1928+
#[derive(Clone, PartialEq, PartialOrd, TyEncodable, TyDecodable, Hash, HashStable)]
19191929
pub enum Operand<'tcx> {
19201930
/// Copy: The value must be available for use afterwards.
19211931
///
@@ -2023,7 +2033,7 @@ impl<'tcx> Operand<'tcx> {
20232033
///////////////////////////////////////////////////////////////////////////
20242034
/// Rvalues
20252035
2026-
#[derive(Clone, TyEncodable, TyDecodable, HashStable, PartialEq)]
2036+
#[derive(Clone, TyEncodable, TyDecodable, Hash, HashStable, PartialEq)]
20272037
pub enum Rvalue<'tcx> {
20282038
/// x (either a move or copy, depending on type of x)
20292039
Use(Operand<'tcx>),
@@ -2069,13 +2079,13 @@ pub enum Rvalue<'tcx> {
20692079
Aggregate(Box<AggregateKind<'tcx>>, Vec<Operand<'tcx>>),
20702080
}
20712081

2072-
#[derive(Clone, Copy, Debug, PartialEq, Eq, TyEncodable, TyDecodable, HashStable)]
2082+
#[derive(Clone, Copy, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)]
20732083
pub enum CastKind {
20742084
Misc,
20752085
Pointer(PointerCast),
20762086
}
20772087

2078-
#[derive(Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, HashStable)]
2088+
#[derive(Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)]
20792089
pub enum AggregateKind<'tcx> {
20802090
/// The type is of the element
20812091
Array(Ty<'tcx>),
@@ -2092,7 +2102,7 @@ pub enum AggregateKind<'tcx> {
20922102
Generator(DefId, SubstsRef<'tcx>, hir::Movability),
20932103
}
20942104

2095-
#[derive(Copy, Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, HashStable)]
2105+
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, TyEncodable, TyDecodable, Hash, HashStable)]
20962106
pub enum BinOp {
20972107
/// The `+` operator (addition)
20982108
Add,
@@ -2137,15 +2147,15 @@ impl BinOp {
21372147
}
21382148
}
21392149

2140-
#[derive(Copy, Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, HashStable)]
2150+
#[derive(Copy, Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)]
21412151
pub enum NullOp {
21422152
/// Returns the size of a value of that type
21432153
SizeOf,
21442154
/// Creates a new uninitialized box for a value of that type
21452155
Box,
21462156
}
21472157

2148-
#[derive(Copy, Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, HashStable)]
2158+
#[derive(Copy, Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)]
21492159
pub enum UnOp {
21502160
/// The `!` operator for logical inversion
21512161
Not,
@@ -2315,7 +2325,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
23152325
/// this does not necessarily mean that they are `==` in Rust. In
23162326
/// particular, one must be wary of `NaN`!
23172327
2318-
#[derive(Clone, Copy, PartialEq, TyEncodable, TyDecodable, HashStable)]
2328+
#[derive(Clone, Copy, PartialEq, PartialOrd, TyEncodable, TyDecodable, Hash, HashStable)]
23192329
pub struct Constant<'tcx> {
23202330
pub span: Span,
23212331

@@ -2449,7 +2459,7 @@ impl<'tcx> UserTypeProjections {
24492459
/// * `let (x, _): T = ...` -- here, the `projs` vector would contain
24502460
/// `field[0]` (aka `.0`), indicating that the type of `s` is
24512461
/// determined by finding the type of the `.0` field from `T`.
2452-
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, PartialEq)]
2462+
#[derive(Clone, Debug, TyEncodable, TyDecodable, Hash, HashStable, PartialEq)]
24532463
pub struct UserTypeProjection {
24542464
pub base: UserTypeAnnotationIndex,
24552465
pub projs: Vec<ProjectionKind>,

compiler/rustc_middle/src/mir/terminator.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::slice;
1717

1818
pub use super::query::*;
1919

20-
#[derive(Debug, Clone, TyEncodable, TyDecodable, HashStable, PartialEq)]
20+
#[derive(Debug, Clone, TyEncodable, TyDecodable, Hash, HashStable, PartialEq, PartialOrd)]
2121
pub struct SwitchTargets {
2222
/// Possible values. The locations to branch to in each case
2323
/// are found in the corresponding indices from the `targets` vector.
@@ -98,7 +98,7 @@ impl<'a> Iterator for SwitchTargetsIter<'a> {
9898

9999
impl<'a> ExactSizeIterator for SwitchTargetsIter<'a> {}
100100

101-
#[derive(Clone, TyEncodable, TyDecodable, HashStable, PartialEq)]
101+
#[derive(Clone, TyEncodable, TyDecodable, Hash, HashStable, PartialEq, PartialOrd)]
102102
pub enum TerminatorKind<'tcx> {
103103
/// Block should have one successor in the graph; we jump there.
104104
Goto { target: BasicBlock },

compiler/rustc_middle/src/ty/adjustment.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_hir::lang_items::LangItem;
66
use rustc_macros::HashStable;
77
use rustc_span::Span;
88

9-
#[derive(Clone, Copy, Debug, PartialEq, Eq, TyEncodable, TyDecodable, HashStable)]
9+
#[derive(Clone, Copy, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)]
1010
pub enum PointerCast {
1111
/// Go from a fn-item type to a fn-pointer type.
1212
ReifyFnPointer,

0 commit comments

Comments
 (0)