rust/compiler
bors e4b9f86054 Auto merge of #109035 - scottmcm:ptr-read-should-know-undef, r=WaffleLapkin,JakobDegen
Ensure `ptr::read` gets all the same LLVM `load` metadata that dereferencing does

I was looking into `array::IntoIter` optimization, and noticed that it wasn't annotating the loads with `noundef` for simple things like `array::IntoIter<i32, N>`.  Trying to narrow it down, it seems that was because `MaybeUninit::assume_init_read` isn't marking the load as initialized (<https://rust.godbolt.org/z/Mxd8TPTnv>), which is unfortunate since that's basically its reason to exist.

The root cause is that `ptr::read` is currently implemented via the *untyped* `copy_nonoverlapping`, and thus the `load` doesn't get any type-aware metadata: no `noundef`, no `!range`.  This PR solves that by lowering `ptr::read(p)` to `copy *p` in MIR, for which the backends already do the right thing.

Fortuitiously, this also improves the IR we give to LLVM for things like `mem::replace`, and fixes a couple of long-standing bugs where `ptr::read` on `Copy` types was worse than `*`ing them.

Zulip conversation: <https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Move.20array.3A.3AIntoIter.20to.20ManuallyDrop/near/341189936>

cc `@erikdesjardins` `@JakobDegen` `@workingjubilee` `@the8472`

Fixes #106369
Fixes #73258
2023-03-15 11:44:12 +00:00
..
rustc fix link 2023-03-11 10:53:47 -06:00
rustc_abi Unify validity checks into a single query 2023-02-23 18:42:36 +00:00
rustc_apfloat
rustc_arena
rustc_ast Remove box_syntax from AST and use in tools 2023-03-12 13:19:46 +00:00
rustc_ast_lowering Auto merge of #104833 - Swatinem:async-identity-future, r=compiler-errors 2023-03-14 10:12:58 +00:00
rustc_ast_passes Auto merge of #108471 - clubby789:unbox-the-syntax, r=Nilstrieb,est31 2023-03-13 10:41:50 +00:00
rustc_ast_pretty Remove box_syntax from AST and use in tools 2023-03-12 13:19:46 +00:00
rustc_attr Simplify message paths 2023-03-11 22:51:57 +01:00
rustc_baked_icu_data update ICU4X to 1.1.0 2023-02-04 22:28:59 +01:00
rustc_borrowck Simplify message paths 2023-03-11 22:51:57 +01:00
rustc_builtin_macros Properly allow macro expanded format_args invocations to uses captures 2023-03-14 13:16:52 +00:00
rustc_codegen_cranelift Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
rustc_codegen_gcc Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
rustc_codegen_llvm Rollup merge of #108726 - est31:backticks_matchmaking_tidy, r=Nilstrieb 2023-03-12 08:13:25 +01:00
rustc_codegen_ssa Rollup merge of #109088 - Nilstrieb:target-feature-on-statics-when, r=compiler-errors 2023-03-13 21:55:39 +01:00
rustc_const_eval Auto merge of #108872 - cjgillot:simp-const-prop, r=oli-obk 2023-03-12 23:27:52 +00:00
rustc_data_structures Rollup merge of #108887 - nnethercote:rename-MapInPlace, r=lqd 2023-03-08 21:24:53 +01:00
rustc_driver Remove unneeded extern crate 2023-02-02 07:47:39 +01:00
rustc_driver_impl Simplify message paths 2023-03-11 22:51:57 +01:00
rustc_error_codes Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
rustc_error_messages Simplify message paths 2023-03-11 22:51:57 +01:00
rustc_errors Simplify message paths 2023-03-11 22:51:57 +01:00
rustc_expand Simplify message paths 2023-03-11 22:51:57 +01:00
rustc_feature Remove box_syntax from AST and use in tools 2023-03-12 13:19:46 +00:00
rustc_fs_util
rustc_graphviz
rustc_hir Rollup merge of #108923 - spastorino:new-rpitit-9, r=compiler-errors 2023-03-14 17:40:05 +01:00
rustc_hir_analysis Auto merge of #109035 - scottmcm:ptr-read-should-know-undef, r=WaffleLapkin,JakobDegen 2023-03-15 11:44:12 +00:00
rustc_hir_pretty Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
rustc_hir_typeck Auto merge of #107376 - aliemjay:remove-givens, r=lcnr 2023-03-15 02:50:58 +00:00
rustc_incremental Auto merge of #108794 - nnethercote:avoid-unnecessary-hashing, r=cjgillot 2023-03-12 06:48:30 +00:00
rustc_index Match unmatched backticks in compiler/ that are part of rustdoc 2023-03-03 08:39:00 +01:00
rustc_infer Auto merge of #107376 - aliemjay:remove-givens, r=lcnr 2023-03-15 02:50:58 +00:00
rustc_interface metadata: Remove some more untracked CStore methods 2023-03-13 17:31:55 +04:00
rustc_lexer fix(lexer): not skipped whitespace warning for '\x0c' 2023-03-09 22:44:58 +08:00
rustc_lint Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
rustc_lint_defs Auto merge of #109035 - scottmcm:ptr-read-should-know-undef, r=WaffleLapkin,JakobDegen 2023-03-15 11:44:12 +00:00
rustc_llvm Remove an extraneous include 2023-03-07 22:46:39 -08:00
rustc_log Rollup merge of #107895 - matthiaskrgr:cl, r=compiler-errors 2023-02-11 17:18:44 +01:00
rustc_macros Allow using bool for optional diagnostics 2023-02-27 12:54:11 +00:00
rustc_metadata Auto merge of #109089 - compiler-errors:opt_rpitit_info-follow-up, r=spastorino 2023-03-15 08:13:23 +00:00
rustc_middle Auto merge of #109089 - compiler-errors:opt_rpitit_info-follow-up, r=spastorino 2023-03-15 08:13:23 +00:00
rustc_mir_build Auto merge of #108820 - cjgillot:ensure-on-disk, r=oli-obk 2023-03-12 14:00:28 +00:00
rustc_mir_dataflow Simplify message paths 2023-03-11 22:51:57 +01:00
rustc_mir_transform Auto merge of #109035 - scottmcm:ptr-read-should-know-undef, r=WaffleLapkin,JakobDegen 2023-03-15 11:44:12 +00:00
rustc_monomorphize Don't codegen impossible to satisfy impls 2023-03-14 16:19:57 +00:00
rustc_parse Auto merge of #108471 - clubby789:unbox-the-syntax, r=Nilstrieb,est31 2023-03-13 10:41:50 +00:00
rustc_parse_format Improve heuristics for format_args literal being suggestable 2023-03-14 13:20:39 +00:00
rustc_passes Auto merge of #109057 - compiler-errors:rpitit-info-again, r=spastorino 2023-03-14 06:42:15 +00:00
rustc_plugin_impl Simplify message paths 2023-03-11 22:51:57 +01:00
rustc_privacy Simplify message paths 2023-03-11 22:51:57 +01:00
rustc_query_impl Ensure value is on the on-disk cache before returning. 2023-03-11 22:41:01 +00:00
rustc_query_system Auto merge of #108845 - Zoxc:par-fix-2, r=cjgillot 2023-03-12 17:03:44 +00:00
rustc_resolve metadata/resolve: Minor refactoring to "tcx -> cstore" conversions 2023-03-13 17:31:55 +04:00
rustc_serialize Emit the enum discriminant separately for the Encodable macro 2023-02-25 01:04:56 +01:00
rustc_session Auto merge of #108794 - nnethercote:avoid-unnecessary-hashing, r=cjgillot 2023-03-12 06:48:30 +00:00
rustc_smir Change item collection to be on demand 2023-03-07 12:47:25 -08:00
rustc_span Auto merge of #109035 - scottmcm:ptr-read-should-know-undef, r=WaffleLapkin,JakobDegen 2023-03-15 11:44:12 +00:00
rustc_symbol_mangling Simplify message paths 2023-03-11 22:51:57 +01:00
rustc_target Rollup merge of #108722 - petrhosek:fuchsia-riscv, r=petrochenkov 2023-03-14 17:40:03 +01:00
rustc_trait_selection Auto merge of #107376 - aliemjay:remove-givens, r=lcnr 2023-03-15 02:50:58 +00:00
rustc_traits Add mk_canonical_var_infos_from_iter. 2023-02-24 07:33:02 +11:00
rustc_transmute rustc_middle: Remove trait DefIdTree 2023-03-02 23:46:44 +04:00
rustc_ty_utils Auto merge of #109089 - compiler-errors:opt_rpitit_info-follow-up, r=spastorino 2023-03-15 08:13:23 +00:00
rustc_type_ir Rollup merge of #109047 - tshepang:type, r=lcnr 2023-03-12 20:44:52 +01:00