rust/compiler/rustc_codegen_llvm/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
..
back replace LLVMRustAppendModuleInlineAsm with LLVMAppendModuleInlineAsm, LLVMRustMetadataTypeInContext with LLVMMetadataTypeInContext 2023-04-04 15:12:35 +03:00
coverageinfo Use IntoIterator for mk_fn_sig. 2023-02-17 22:24:34 +11:00
debuginfo Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillot 2023-04-18 22:27:15 +00:00
llvm Auto merge of #109862 - klensy:llvm-dd, r=nikic 2023-04-08 15:57:59 +00:00
abi.rs Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
allocator.rs Add LLVM KCFI support to the Rust compiler 2022-12-08 17:24:39 -08:00
asm.rs Add inline assembly support for m68k 2023-04-12 17:58:15 -07:00
attributes.rs Add kernel-address sanitizer support for freestanding targets 2023-02-14 20:54:25 -05:00
base.rs Remove several unused methods from MiscMethods 2022-10-01 16:45:07 +00:00
builder.rs fixup: use Bool instead of bool 2023-04-08 12:15:26 +03:00
callee.rs Remove type-traversal trait aliases 2023-02-22 17:04:58 +00:00
common.rs Store hashes in special types so they aren't accidentally encoded as numbers 2023-04-18 10:52:47 -04:00
consts.rs review 2023-04-05 15:08:17 +03:00
context.rs Auto merge of #95317 - Jules-Bertholet:round_ties_to_even, r=pnkfelix,m-ou-se,scottmcm 2023-03-07 09:43:12 +00:00
declare.rs Add LLVM KCFI support to the Rust compiler 2022-12-08 17:24:39 -08:00
errors.rs errors: generate typed identifiers in each crate 2023-02-22 09:15:53 +00:00
intrinsic.rs Add CastKind::Transmute to MIR 2023-03-22 15:15:41 -07:00
lib.rs Spelling - compiler 2023-04-17 16:09:18 -04:00
llvm_util.rs More general captures 2023-03-22 15:39:24 +01:00
mono_item.rs Remove type-traversal trait aliases 2023-02-22 17:04:58 +00:00
type_.rs replace LLVMRustAppendModuleInlineAsm with LLVMAppendModuleInlineAsm, LLVMRustMetadataTypeInContext with LLVMMetadataTypeInContext 2023-04-04 15:12:35 +03:00
type_of.rs Remove type-traversal trait aliases 2023-02-22 17:04:58 +00:00
va_arg.rs Implement va_list and va_arg for s390x FFI 2022-12-19 21:07:57 +01:00
value.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00