1
Fork 0
rust/compiler/rustc_mir_transform/src
bors b3f1379509 Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillot
Encode hashes as bytes, not varint

In a few places, we store hashes as `u64` or `u128` and then apply `derive(Decodable, Encodable)` to the enclosing struct/enum. It is more efficient to encode hashes directly than try to apply some varint encoding. This PR adds two new types `Hash64` and `Hash128` which are produced by `StableHasher` and replace every use of storing a `u64` or `u128` that represents a hash.

Distribution of the byte lengths of leb128 encodings, from `x build --stage 2` with `incremental = true`

Before:
```
(  1) 373418203 (53.7%, 53.7%): 1
(  2) 196240113 (28.2%, 81.9%): 3
(  3) 108157958 (15.6%, 97.5%): 2
(  4)  17213120 ( 2.5%, 99.9%): 4
(  5)    223614 ( 0.0%,100.0%): 9
(  6)    216262 ( 0.0%,100.0%): 10
(  7)     15447 ( 0.0%,100.0%): 5
(  8)      3633 ( 0.0%,100.0%): 19
(  9)      3030 ( 0.0%,100.0%): 8
( 10)      1167 ( 0.0%,100.0%): 18
( 11)      1032 ( 0.0%,100.0%): 7
( 12)      1003 ( 0.0%,100.0%): 6
( 13)        10 ( 0.0%,100.0%): 16
( 14)        10 ( 0.0%,100.0%): 17
( 15)         5 ( 0.0%,100.0%): 12
( 16)         4 ( 0.0%,100.0%): 14
```

After:
```
(  1) 372939136 (53.7%, 53.7%): 1
(  2) 196240140 (28.3%, 82.0%): 3
(  3) 108014969 (15.6%, 97.5%): 2
(  4)  17192375 ( 2.5%,100.0%): 4
(  5)       435 ( 0.0%,100.0%): 5
(  6)        83 ( 0.0%,100.0%): 18
(  7)        79 ( 0.0%,100.0%): 10
(  8)        50 ( 0.0%,100.0%): 9
(  9)         6 ( 0.0%,100.0%): 19
```

The remaining 9 or 10 and 18 or 19 are `u64` and `u128` respectively that have the high bits set. As far as I can tell these are coming primarily from `SwitchTargets`.
2023-04-18 22:27:15 +00:00
..
coverage Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillot 2023-04-18 22:27:15 +00:00
inline Support TLS access into dylibs on Windows 2023-03-29 08:55:21 +02:00
abort_unwinding_calls.rs Add UnwindAction::Terminate 2023-04-06 09:34:16 +01:00
add_call_guards.rs UnwindAction::Terminate edge is also critical edge 2023-04-06 22:24:47 +01:00
add_moves_for_packed_drops.rs Spelling - compiler 2023-04-17 16:09:18 -04:00
add_retag.rs Spelling - compiler 2023-04-17 16:09:18 -04:00
check_alignment.rs Only emit alignment checks if we have a panic_impl 2023-04-13 10:58:00 -04:00
check_const_item_mutation.rs Move some utils out of rustc_const_eval 2023-04-16 12:05:54 +02:00
check_packed_ref.rs Properly check for builtin derives 2023-02-16 19:44:03 +00:00
check_unsafety.rs Rename Abort terminator to Terminate 2023-04-06 09:34:16 +01:00
cleanup_post_borrowck.rs Introduce a no-op PlaceMention statement for let _ =. 2023-03-09 17:45:13 +00:00
const_debuginfo.rs Spelling - compiler 2023-04-17 16:09:18 -04:00
const_goto.rs Disable ConstGoto opt in cleanup blocks 2023-01-26 03:50:37 -08:00
const_prop.rs Spelling - compiler 2023-04-17 16:09:18 -04:00
const_prop_lint.rs fix clippy::toplevel_ref_arg and ::manual_map 2023-04-16 13:28:13 +02:00
copy_prop.rs Use &IndexSlice instead of &IndexVec where possible 2023-04-02 17:35:37 -07:00
ctfe_limit.rs don't into self 2023-02-16 18:30:25 +01:00
dataflow_const_prop.rs Spelling - compiler 2023-04-17 16:09:18 -04:00
dead_store_elimination.rs Introduce a no-op PlaceMention statement for let _ =. 2023-03-09 17:45:13 +00:00
deduce_param_attrs.rs Check freeze with right param-env 2023-04-16 23:09:57 +00:00
deduplicate_blocks.rs Replace Body::basic_blocks() with field access 2022-08-26 14:27:08 +02:00
deref_separator.rs Wrap the whole LocalInfo in ClearCrossCrate. 2023-03-14 20:52:42 +01:00
dest_prop.rs Spelling - compiler 2023-04-17 16:09:18 -04:00
dump_mir.rs Auto merge of #105220 - oli-obk:feeding, r=cjgillot 2022-12-06 03:47:41 +00:00
early_otherwise_branch.rs Remove unneeded field from SwitchTargets 2022-12-09 04:53:10 -08:00
elaborate_box_derefs.rs Update ty::VariantDef to use IndexVec<FieldIdx, FieldDef> 2023-03-30 09:23:40 -07:00
elaborate_drops.rs Spelling - compiler 2023-04-17 16:09:18 -04:00
ffi_unwind_calls.rs LocalCrate key 2023-03-21 15:38:52 +00:00
function_item_references.rs Refactor unwind from Option to a new enum 2023-04-06 09:34:16 +01:00
generator.rs Spelling - compiler 2023-04-17 16:09:18 -04:00
inline.rs Permit MIR inlining without #[inline] 2023-04-07 15:46:43 -04:00
instcombine.rs Move mir::Fieldabi::FieldIdx 2023-03-28 22:22:37 -07:00
large_enums.rs Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
lib.rs Remove outdated comment. 2023-04-15 07:46:46 +00:00
lower_intrinsics.rs Move mir::Fieldabi::FieldIdx 2023-03-28 22:22:37 -07:00
lower_slice_len.rs Add UnwindAction::Terminate 2023-04-06 09:34:16 +01:00
match_branches.rs Remove unneeded field from SwitchTargets 2022-12-09 04:53:10 -08:00
multiple_return_terminators.rs Replace Body::basic_blocks() with field access 2022-08-26 14:27:08 +02:00
normalize_array_len.rs Remove obsolete comment. 2023-01-29 22:09:51 +00:00
nrvo.rs Remove LocalKind::Var. 2023-03-14 20:52:42 +01:00
pass_manager.rs Use zero based indexing for pass_count 2022-12-02 15:55:24 +00:00
remove_noop_landing_pads.rs Rename Abort terminator to Terminate 2023-04-06 09:34:16 +01:00
remove_storage_markers.rs Make MIR basic blocks field public 2022-07-07 08:11:49 +02:00
remove_uninit_drops.rs Move mir::Fieldabi::FieldIdx 2023-03-28 22:22:37 -07:00
remove_unneeded_drops.rs Make MIR basic blocks field public 2022-07-07 08:11:49 +02:00
remove_zsts.rs Generalize operation. 2023-03-13 18:22:55 +00:00
required_consts.rs Don't ICE when encountering ConstKind::Error in RequiredConstsVisitor 2022-11-10 05:14:04 +00:00
reveal_all.rs Add option to mir::MutVisitor to not invalidate CFG. 2022-08-09 01:51:10 -07:00
separate_const_switch.rs Rename Abort terminator to Terminate 2023-04-06 09:34:16 +01:00
shim.rs Address review feedback 2023-04-06 09:34:16 +01:00
simplify.rs Use &IndexSlice instead of &IndexVec where possible 2023-04-02 17:35:37 -07:00
simplify_branches.rs Remove unneeded field from SwitchTargets 2022-12-09 04:53:10 -08:00
simplify_comparison_integral.rs Remove unneeded field from SwitchTargets 2022-12-09 04:53:10 -08:00
sroa.rs Move mir::Fieldabi::FieldIdx 2023-03-28 22:22:37 -07:00
ssa.rs Spelling - compiler 2023-04-17 16:09:18 -04:00
uninhabited_enum_branching.rs move things from rustc_target::abi to rustc_abi 2022-11-24 16:26:13 +03:30
unreachable_prop.rs Fix typos in compiler 2023-04-10 22:02:52 +02:00