rust/compiler/rustc_codegen_llvm/src
bors 0e7f91b75e Auto merge of #118324 - RalfJung:ctfe-read-only-pointers, r=saethlin
compile-time evaluation: detect writes through immutable pointers

This has two motivations:
- it unblocks https://github.com/rust-lang/rust/pull/116745 (and therefore takes a big step towards `const_mut_refs` stabilization), because we can now detect if the memory that we find in `const` can be interned as "immutable"
- it would detect the UB that was uncovered in https://github.com/rust-lang/rust/pull/117905, which was caused by accidental stabilization of `copy` functions in `const` that can only be called with UB

When UB is detected, we emit a future-compat warn-by-default lint. This is not a breaking change, so completely in line with [the const-UB RFC](https://rust-lang.github.io/rfcs/3016-const-ub.html), meaning we don't need t-lang FCP here. I made the lint immediately show up for dependencies since it is nearly impossible to even trigger this lint without `const_mut_refs` -- the accidentally stabilized `copy` functions are the only way this can happen, so the crates that popped up in #117905 are the only causes of such UB (in the code that crater covers), and the three cases of UB that we know about have all been fixed in their respective crates already.

The way this is implemented is by making use of the fact that our interpreter is already generic over the notion of provenance. For CTFE we now use the new `CtfeProvenance` type which is conceptually an `AllocId` plus a boolean `immutable` flag (but packed for a more efficient representation). This means we can mark a pointer as immutable when it is created as a shared reference. The flag will be propagated to all pointers derived from this one. We can then check the immutable flag on each write to reject writes through immutable pointers.

I just hope perf works out.
2023-12-07 18:11:01 +00:00
..
back Auto merge of #113923 - DianQK:restore-no-builtins-lto, r=pnkfelix 2023-12-01 21:45:18 +00:00
coverageinfo merge DefKind::Coroutine into DefKind::Closure 2023-11-26 21:05:08 +08:00
debuginfo Fix clippy::needless_borrow in the compiler 2023-11-21 20:13:40 +01:00
llvm Auto merge of #113923 - DianQK:restore-no-builtins-lto, r=pnkfelix 2023-12-01 21:45:18 +00:00
abi.rs Fix clippy::needless_borrow in the compiler 2023-11-21 20:13:40 +01:00
allocator.rs Fix clippy::needless_borrow in the compiler 2023-11-21 20:13:40 +01:00
asm.rs Auto merge of #114467 - Amanieu:asm-unstable-features, r=davidtwco 2023-08-15 11:59:02 +00:00
attributes.rs Add -Zfunction-return={keep,thunk-extern} option 2023-11-30 20:21:31 +01:00
base.rs cg_llvm: remove pointee types and pointercast/bitcast-of-ptr 2023-07-29 13:18:17 -04:00
builder.rs more targeted errors when extern types end up in places they should not 2023-12-03 08:11:15 +01:00
callee.rs Fix clippy::needless_borrow in the compiler 2023-11-21 20:13:40 +01:00
common.rs ctfe interpreter: extend provenance so that it can track whether a pointer is immutable 2023-12-07 17:46:36 +01:00
consts.rs ctfe interpreter: extend provenance so that it can track whether a pointer is immutable 2023-12-07 17:46:36 +01:00
context.rs Auto merge of #117947 - Dirbaio:drop-llvm-15, r=cuviper 2023-11-27 21:54:03 +00:00
declare.rs CFI: Fix SIGILL reached via trait objects 2023-05-09 20:04:19 +00:00
errors.rs De-genericize some IntoDiagnostic impls. 2023-12-04 18:57:42 +11:00
intrinsic.rs Merge simd size and type extraction into checking whether a type is simd, as these always go together. 2023-10-31 11:23:39 +00:00
lib.rs Update compiler/rustc_codegen_llvm/src/lib.rs 2023-11-29 18:12:53 -06:00
llvm_util.rs Rollup merge of #118142 - saethlin:llvm-linkage, r=tmiasko 2023-11-22 09:28:51 -08:00
mono_item.rs use visibility to check unused imports and delete some stmts 2023-10-22 21:27:46 +08:00
type_.rs remove unused pub fn 2023-11-23 14:11:02 +03:00
type_of.rs Clean dead codes 2023-11-26 09:25:07 +08:00
va_arg.rs cg_llvm: remove pointee types and pointercast/bitcast-of-ptr 2023-07-29 13:18:17 -04:00
value.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00