summary refs log tree commit diff
path: root/compiler/rustc_mir/src/transform
AgeCommit message (Collapse)AuthorLines
2021-08-27Split critical edge targeting the start blockTomasz Miąsko-1/+3
2021-07-19Iterate through impls only when permittedDeadbeef-8/+11
2021-07-17Auto merge of #87123 - RalfJung:miri-provenance-overhaul, r=oli-obkbors-17/+10
CTFE/Miri engine Pointer type overhaul This fixes the long-standing problem that we are using `Scalar` as a type to represent pointers that might be integer values (since they point to a ZST). The main problem is that with int-to-ptr casts, there are multiple ways to represent the same pointer as a `Scalar` and it is unclear if "normalization" (i.e., the cast) already happened or not. This leads to ugly methods like `force_mplace_ptr` and `force_op_ptr`. Another problem this solves is that in Miri, it would make a lot more sense to have the `Pointer::offset` field represent the full absolute address (instead of being relative to the `AllocId`). This means we can do ptr-to-int casts without access to any machine state, and it means that the overflow checks on pointer arithmetic are (finally!) accurate. To solve this, the `Pointer` type is made entirely parametric over the provenance, so that we can use `Pointer<AllocId>` inside `Scalar` but use `Pointer<Option<AllocId>>` when accessing memory (where `None` represents the case that we could not figure out an `AllocId`; in that case the `offset` is an absolute address). Moreover, the `Provenance` trait determines if a pointer with a given provenance can be cast to an integer by simply dropping the provenance. I hope this can be read commit-by-commit, but the first commit does the bulk of the work. It introduces some FIXMEs that are resolved later. Fixes https://github.com/rust-lang/miri/issues/841 Miri PR: https://github.com/rust-lang/miri/pull/1851 r? `@oli-obk`
2021-07-16get rid of incorrect erase_for_fmtRalf Jung-2/+2
2021-07-15adjustions and cleanup to make Miri build againRalf Jung-1/+1
2021-07-14consistently treat None-tagged pointers as ints; get rid of some deprecated ↵Ralf Jung-5/+4
Scalar methods
2021-07-14CTFE/Miri engine Pointer type overhaul: make Scalar-to-Pointer conversion ↵Ralf Jung-11/+5
infallible This resolves all the problems we had around "normalizing" the representation of a Scalar in case it carries a Pointer value: we can just use Pointer if we want to have a value taht we are sure is already normalized.
2021-07-13Auto merge of #87044 - cjgillot:expnhash, r=petrochenkovbors-1/+2
Cache expansion hash globally ... instead of computing it multiple times. Split from #86676 r? `@petrochenkov`
2021-07-13Cache expansion hash.Camille GILLOT-1/+2
2021-07-13Auto merge of #86857 - fee1-dead:add-attr, r=oli-obkbors-2/+28
Add #[default_method_body_is_const] `@rustbot` label F-const_trait_impl
2021-07-10rustc_span: Revert addition of `proc_macro` field to `ExpnKind::Macro`Vadim Petrochenkov-5/+2
The flag has a vague meaning and is used for a single diagnostic change that is low benefit and appears only under `-Z macro_backtrace`.
2021-07-11Rollup merge of #87028 - aDotInTheVoid:patch-1, r=petrochenkovYuki Okushi-1/+1
Fix type: `'satic` -> `'static` Pointed out on discord: https://discord.com/channels/273534239310479360/490356824420122645/863434443170250793 ~~The fact that this compiles is probably a bug.~~ Nope it's `#![feature(in_band_lifetimes)]` (Thanks to [floppy](https://discord.com/channels/273534239310479360/490356824420122645/863437381671059486) ~~[The docs](https://doc.rust-lang.org/stable/nightly-rustc/rustc_mir/transform/inline/struct.Inliner.html#method.check_codegen_attributes) seem to indicate rust thinks this function is generic over the lifetime `'satic`~~ This is because of `in_band_lifetimes`
2021-07-10Fix typo: `satic` -> `static`Nixon Enraght-Moony-1/+1
2021-07-10Permit calls to default const fns of impl constDeadbeef-7/+25
2021-07-10Skip check for calling functions in same traitDeadbeef-3/+11
2021-07-10remove const_raw_ptr_to_usize_cast featureRalf Jung-40/+16
2021-07-08Rework SESSION_GLOBALS API to prevent overwriting itGuillaume Gomez-2/+2
2021-07-06Store macro parent module in ExpnData.Camille GILLOT-1/+1
2021-07-04Combine individual limit queries into single `limits` queryAaron Hill-1/+1
2021-07-04Query-ify global limit attribute handlingAaron Hill-3/+15
2021-07-04Auto merge of #86255 - Smittyvb:mir-alloc-oom, r=RalfJung,oli-obkbors-1/+6
Support allocation failures when interpreting MIR This closes #79601 by handling the case where memory allocation fails during MIR interpretation, and translates that failure into an `InterpError`. The error message is "tried to allocate more memory than available to compiler" to make it clear that the memory shortage is happening at compile-time by the compiler itself, and that it is not a runtime issue. Now that memory allocation can fail, it would be neat if Miri could simulate low-memory devices to make it easy to see how much memory a Rust program needs. Note that this breaks Miri because it assumes that allocation can never fail.
2021-07-03add note about MAX_ALLOC_LIMITSmittyvb-1/+1
Co-authored-by: Ralf Jung <post@ralfj.de>
2021-07-02Allocation failure in constprop panics right awaySmitty-0/+1
2021-07-03Remove `ty::Binder::bind()`Yuki Okushi-6/+1
Co-authored-by: Noah Lev <camelidcamel@gmail.com>
2021-06-30Delay ICE on evaluation failSmitty-68/+15
2021-06-30Properly evaluate non-consts in const propSmitty-8/+51
2021-06-30Simplify memory failure checkingSmitty-17/+16
2021-06-30Rename is_spurious -> is_volatileSmitty-2/+2
2021-06-29Properly handle const prop failuresSmitty-0/+13
2021-06-29Simplify const_prop logicSmitty-11/+9
2021-06-29Support allocation failures when interperting MIRSmitty-7/+11
Note that this breaks Miri. Closes #79601
2021-06-25Auto merge of #85603 - ogoffart:fix-uninhabited-enum-branching-pass, ↵bors-7/+5
r=wesleywiser Fix uninhabited enum branching pass when the discriminant is taken with some projection.
2021-06-22Rollup merge of #86517 - camsteffen:unused-unsafe-async, r=LeSeulArtichautYuki Okushi-0/+1
Fix `unused_unsafe` around `await` Enables `unused_unsafe` lint for `unsafe { future.await }`. The existing test for this is `unsafe { println!() }`, so I assume that `println!` used to contain compiler-generated unsafe but this is no longer true, and so the existing test is broken. I replaced the test with `unsafe { ...await }`. I believe `await` is currently the only instance of compiler-generated unsafe. Reverts some parts of #85421, but the issue predates that PR.
2021-06-21Fix unused_unsafe with compiler-generated unsafeCameron Steffen-0/+1
2021-06-21Auto merge of #86383 - shamatar:slice_len_lowering, r=bjorn3bors-0/+102
Add MIR pass to lower call to `core::slice::len` into `Len` operand During some larger experiment with range analysis I've found that code like `let l = slice.len()` produces different MIR then one found in bound checks. This optimization pass replaces terminators that are calls to `core::slice::len` with just a MIR operand and Goto terminator. It uses some heuristics to remove the outer borrow that is made to call `core::slice::len`, but I assume it can be eliminated, just didn't find how. Would like to express my gratitude to `@oli-obk` who helped me a lot on Zullip
2021-06-20Squashed implementation of the passAlex Vlasov-0/+102
2021-06-19Rollup merge of #86407 - LingMan:map-or, r=LeSeulArtichautYuki Okushi-6/+3
Use `map_or` instead of open-coding it `@rustbot` modify labels +C-cleanup +T-compiler
2021-06-18Auto merge of #85421 - Smittyvb:rm_pushpop_unsafe, r=matthewjasperbors-1/+0
Remove some last remants of {push,pop}_unsafe! These macros have already been removed, but there was still some code handling these macros. That code is now removed.
2021-06-17Use `map_or` instead of open-coding itLingMan-6/+3
2021-06-16Stop returning a value from `report_assert_as_lint`LingMan-11/+14
This function only ever returns `None`. Make that explicity by not returning a value at all.
2021-06-09Auto merge of #86107 - Smittyvb:peephole-optim-eq-bool, r=wesleywiserbors-7/+14
Peephole optimize `x == false` and `x != true` This adds peephole optimizations to make `x == false`, `false == x`, `x != true`, and `true != x` get optimized to `!x` in the `instcombine` MIR pass. That pass currently handles `x == true` -> `x` already.
2021-06-07Peephole optimize `x == false` and `x != true`Smitty-7/+14
2021-06-07Rollup merge of #85973 - LingMan:indentation, r=jyn514Yuki Okushi-25/+22
Replace a `match` with an `if let` Seems like a better fit here and saves one level of indentation. `@rustbot` modify labels +C-cleanup +T-compiler
2021-06-06Remove some last remants of {push,pop}_unsafe!Smitty-1/+0
These macros have already been removed, but there was still some code handling these macros. That code is now removed.
2021-06-05Drop an `if let` that will always succeedLingMan-7/+5
We've already checked that `proj_base == []` in the line above and renaming `place_local` to `local` doesn't gain us anything.
2021-06-04Auto merge of #85385 - richkadel:simpler-simplify-with-coverage, r=wesleywiserbors-16/+91
Reland - Report coverage `0` of dead blocks Fixes: #84018 With `-Z instrument-coverage`, coverage reporting of dead blocks (for example, blocks dropped because a conditional branch is dropped, based on const evaluation) is now supported. Note, this PR relands an earlier, reverted PR that failed when compiling generators. The prior issues with generators has been resolved and a new test was added to prevent future regressions. Check out the resulting changes to test coverage of dead blocks in the test coverage reports in this PR. r? `@tmandry` fyi: `@wesleywiser`
2021-06-03Replace a `match` with an `if let`LingMan-25/+22
Seems like a better fit here and saves one level of indentation.
2021-06-03Auto merge of #85952 - JohnTitor:rollup-r00gu9q, r=JohnTitorbors-38/+33
Rollup of 13 pull requests Successful merges: - #83362 (Stabilize `vecdeque_binary_search`) - #85706 (Turn off frame pointer elimination on all Apple platforms. ) - #85724 (Fix issue 85435 by restricting Fake Read precision) - #85852 (Clarify meaning of MachineApplicable suggestions.) - #85877 (Intra doc link-ify a reference to a function) - #85880 (convert assertion on rvalue::threadlocalref to delay bug) - #85896 (Add test for forward declared const param defaults) - #85897 (Update I-unsound label for triagebot) - #85900 (Use pattern matching instead of checking lengths explicitly) - #85911 (Avoid a clone of output_filenames.) - #85926 (Update cargo) - #85934 (Add `Ty::is_union` predicate) - #85935 (Validate type of locals used as indices) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-06-03Rollup merge of #85935 - tmiasko:validate-indexing, r=jonas-schievinkYuki Okushi-2/+20
Validate type of locals used as indices
2021-06-03Rollup merge of #85934 - tmiasko:is-union, r=jackh726Yuki Okushi-32/+10
Add `Ty::is_union` predicate