granite-rust/compiler
bors 20997f6ad8 Auto merge of #83698 - erikdesjardins:undefconst, r=RalfJung,oli-obk
Use undef for uninitialized bytes in constants

Fixes #83657

This generates good code when the const is fully uninit, e.g.

```rust
#[no_mangle]
pub const fn fully_uninit() -> MaybeUninit<[u8; 10]> {
    const M: MaybeUninit<[u8; 10]> = MaybeUninit::uninit();
    M
}
```
generates
```asm
fully_uninit:
	ret
```

as you would expect.

There is no improvement, however, when it's partially uninit, e.g.

```rust
pub struct PartiallyUninit {
    x: u64,
    y: MaybeUninit<[u8; 10]>
}

#[no_mangle]
pub const fn partially_uninit() -> PartiallyUninit {
    const X: PartiallyUninit = PartiallyUninit { x: 0xdeadbeefcafe, y: MaybeUninit::uninit() };
    X
}
```
generates
```asm
partially_uninit:
	mov	rax, rdi
	mov	rcx, qword ptr [rip + .L__unnamed_1+16]
	mov	qword ptr [rdi + 16], rcx
	movups	xmm0, xmmword ptr [rip + .L__unnamed_1]
	movups	xmmword ptr [rdi], xmm0
	ret

.L__unnamed_1:
	.asciz	"\376\312\357\276\255\336\000"
	.zero	16
	.size	.L__unnamed_1, 24
```
which copies a bunch of zeros in place of the undef bytes, the same as before this change.

Edit: generating partially-undef constants isn't viable at the moment anyways due to #84565, so it's disabled
2021-08-26 10:49:25 +00:00
..
rustc rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rustc_apfloat rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rustc_arena rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rustc_ast Auto merge of #88066 - LeSeulArtichaut:patterns-cleanups, r=nagisa 2021-08-26 05:23:35 +00:00
rustc_ast_lowering Move named_asm_labels to a HIR lint 2021-08-24 08:23:58 -04:00
rustc_ast_passes Remove Session.used_attrs and move logic to CheckAttrVisitor 2021-08-21 13:27:27 -05:00
rustc_ast_pretty Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
rustc_attr Remove Session.used_attrs and move logic to CheckAttrVisitor 2021-08-21 13:27:27 -05:00
rustc_builtin_macros Move named_asm_labels to a HIR lint 2021-08-24 08:23:58 -04:00
rustc_codegen_cranelift Auto merge of #88135 - crlf0710:trait_upcasting_part_3, r=nikomatsakis 2021-08-21 21:14:07 +00:00
rustc_codegen_llvm improve comment 2021-08-25 17:49:28 -04:00
rustc_codegen_ssa Auto merge of #88242 - bonega:allocation_range, r=oli-obk 2021-08-25 02:17:41 +00:00
rustc_data_structures Also fix “a OwningRef 2021-08-24 02:28:38 +02:00
rustc_driver Reduce verbosity of RUSTC_LOG 2021-08-09 21:39:39 -04:00
rustc_error_codes Detect incorrect number of lang item generics 2021-08-23 10:15:25 -04:00
rustc_errors Use if-let guards in the codebase 2021-08-25 20:24:35 +02:00
rustc_expand Various pattern cleanups 2021-08-25 20:24:39 +02:00
rustc_feature Auto merge of #87937 - LeSeulArtichaut:active-if-let-guards, r=nagisa 2021-08-25 13:42:02 +00:00
rustc_fs_util rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rustc_graphviz rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rustc_hir Rollup merge of #88196 - asquared31415:named-asm-labels-refactor, r=Amanieu 2021-08-25 15:48:50 +02:00
rustc_hir_pretty Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
rustc_incremental Remove Session.used_attrs and move logic to CheckAttrVisitor 2021-08-21 13:27:27 -05:00
rustc_index rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rustc_infer Rollup merge of #88218 - Aaron1011:missing-method-dyn, r=nagisa 2021-08-25 15:48:51 +02:00
rustc_interface don't generate partially-undef consts 2021-08-25 17:49:28 -04:00
rustc_lexer Fix more “a”/“an” typos 2021-08-22 17:27:18 +02:00
rustc_lint Rollup merge of #88196 - asquared31415:named-asm-labels-refactor, r=Amanieu 2021-08-25 15:48:50 +02:00
rustc_lint_defs Move named_asm_labels to a HIR lint 2021-08-24 08:23:58 -04:00
rustc_llvm Rollup merge of #88164 - durin42:llvm-14-san-opts, r=nikic 2021-08-22 20:52:53 +02:00
rustc_macros Rollup merge of #86123 - Aaron1011:query-span, r=cjgillot 2021-08-19 19:30:04 +02:00
rustc_metadata Auto merge of #85344 - cbeuw:remap-across-cwd, r=michaelwoerister 2021-08-25 10:58:43 +00:00
rustc_middle Auto merge of #83698 - erikdesjardins:undefconst, r=RalfJung,oli-obk 2021-08-26 10:49:25 +00:00
rustc_mir Auto merge of #85499 - jackh726:assoc-type-norm-rebase, r=nikomatsakis 2021-08-25 20:08:00 +00:00
rustc_mir_build Fix typos “an”→“a” and a few different ones that appeared in the same search 2021-08-22 18:15:49 +02:00
rustc_parse Use if-let guards in the codebase 2021-08-25 20:24:35 +02:00
rustc_parse_format rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rustc_passes Auto merge of #87875 - asquared31415:generic-lang-items, r=cjgillot 2021-08-25 08:12:16 +00:00
rustc_plugin_impl Remove Session.used_attrs and move logic to CheckAttrVisitor 2021-08-21 13:27:27 -05:00
rustc_privacy Auto merge of #87739 - Aaron1011:remove-used-attrs, r=wesleywiser 2021-08-24 03:58:22 +00:00
rustc_query_impl Fold vtable_trait_upcasting_coercion_new_vptr_slot logic into obligation processing. 2021-08-18 13:00:27 +08:00
rustc_query_system Prevent double panic when handling incremental fingerprint mismatch 2021-08-12 15:11:39 -05:00
rustc_resolve Auto merge of #87739 - Aaron1011:remove-used-attrs, r=wesleywiser 2021-08-24 03:58:22 +00:00
rustc_save_analysis Use if-let guards in the codebase 2021-08-25 20:24:35 +02:00
rustc_serialize Fix more “a”/“an” typos 2021-08-22 16:35:29 +02:00
rustc_session don't generate partially-undef consts 2021-08-25 17:49:28 -04:00
rustc_span Use if-let guards in the codebase 2021-08-25 20:24:35 +02:00
rustc_symbol_mangling Remove Session.used_attrs and move logic to CheckAttrVisitor 2021-08-21 13:27:27 -05:00
rustc_target use undef for uninitialized bytes in constants 2021-08-25 17:49:28 -04:00
rustc_trait_selection Review comments 2021-08-24 22:29:41 -04:00
rustc_traits Fix typos “a”→“an” 2021-08-22 15:35:11 +02:00
rustc_ty_utils Fix typos “a”→“an” 2021-08-22 15:35:11 +02:00
rustc_type_ir rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rustc_typeck Auto merge of #88066 - LeSeulArtichaut:patterns-cleanups, r=nagisa 2021-08-26 05:23:35 +00:00