diff options
| author | bors <bors@rust-lang.org> | 2021-01-12 17:26:56 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-01-12 17:26:56 +0000 |
| commit | 704e47f78b4c8801a3c76f235a5a152e1b60b300 (patch) | |
| tree | 867a118a9e4fd8490e80316fd699e8533a2c0815 /compiler/rustc_codegen_llvm/src/context.rs | |
| parent | 497c9a256b1c2961e91565ccc6e0dd3a87a031ed (diff) | |
| parent | 53e3a23572b599844653fe8f4add4a02966dcd9b (diff) | |
| download | rust-704e47f78b4c8801a3c76f235a5a152e1b60b300.tar.gz rust-704e47f78b4c8801a3c76f235a5a152e1b60b300.zip | |
Auto merge of #78407 - oli-obk:ub_checkable_ctfe, r=RalfJung,pnkfelix
Make CTFE able to check for UB... ... by not doing any optimizations on the `const fn` MIR used in CTFE. This means we duplicate all `const fn`'s MIR now, once for CTFE, once for runtime. This PR is for checking the perf effect, so we have some data when talking about https://github.com/rust-lang/const-eval/blob/master/rfcs/0000-const-ub.md To do this, we now have two queries for obtaining mir: `optimized_mir` and `mir_for_ctfe`. It is now illegal to invoke `optimized_mir` to obtain the MIR of a const/static item's initializer, an array length, an inline const expression or an enum discriminant initializer. For `const fn`, both `optimized_mir` and `mir_for_ctfe` work, the former returning the MIR that LLVM should use if the function is called at runtime. Similarly it is illegal to invoke `mir_for_ctfe` on regular functions. This is all checked via appropriate assertions and I don't think it is easy to get wrong, as there should be no `mir_for_ctfe` calls outside the const evaluator or metadata encoding. Almost all rustc devs should keep using `optimized_mir` (or `instance_mir` for that matter).
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/context.rs')
0 files changed, 0 insertions, 0 deletions
