about summary refs log tree commit diff
path: root/src/test/mir-opt
AgeCommit message (Collapse)AuthorLines
2020-05-04Rollup merge of #71697 - felix91gr:new_prop_into_fn_call, r=wesleywiserDylan DPC-5/+30
Added MIR constant propagation of Scalars into function call arguments Now for the function call arguments! Caveats: 1. It's only being enabled at `mir-opt-2` or higher, because currently codegen gives performance regressions with this optimization. 2. Only propagates Scalars. Tuples and references (references are `Indirect`, right??) are not being propagated into as of this PR. 3. Maybe more tests would be nice? 4. I need (shamefully) to ask @wesleywiser to write in his words (or explain to me, and then I can write it down) why we want to ignore propagation into `ScalarPairs` and `Indirect` arguments. r? @wesleywiser
2020-05-02Added MIR constant propagation of Scalars into function call argumentsFélix Fischer-5/+30
- Documented rationale of current solution - Polished documentation
2020-04-30Rollup merge of #71590 - RalfJung:mir-dump-pointers, r=oli-obkTyler Mandry-36/+36
MIR dump: print pointers consistently with Miri output This makes MIR allocation dump pointer printing consistent with Miri output: both use hexadecimal offsets with a `0x` prefix. To save some space, MIR dump replaces the `alloc` prefix by `a` when necessary. I also made AllocId/Pointer printing more consistent in their Debug/Display handling, and adjusted Display printing for Scalar a bit to avoid using decimal printing when we do not know the sign with which to interpret the value (IMO using decimal then is misleading).
2020-04-30Rollup merge of #70950 - nikomatsakis:leak-check-nll-2, r=matthewjasperDylan DPC-161/+167
extend NLL checker to understand `'empty` combined with universes This PR extends the NLL region checker to understand `'empty` combined with universes. In particular, it means that the NLL region checker no longer considers `exists<R2> { forall<R1> { R1: R2 } }` to be provable. This is work towards https://github.com/rust-lang/rust/issues/59490, but we're not all the way there. One thing in particular it does not address is error messages. The modifications to the NLL region inference code turned out to be simpler than expected. The main change is to require that if `R1: R2` then `universe(R1) <= universe(R2)`. This constraint follows from the region lattice (shown below), because we assume then that `R2` is "at least" `empty(Universe(R2))`, and hence if `R1: R2` (i.e., `R1 >= R2` on the lattice) then `R1` must be in some universe that can name `'empty(Universe(R2))`, which requires that `Universe(R1) <= Universe(R2)`. ``` static ----------+-----...------+ (greatest) | | | early-bound and | | free regions | | | | | scope regions | | | | | empty(root) placeholder(U1) | | / | | / placeholder(Un) empty(U1) -- / | / ... / | / empty(Un) -------- (smallest) ``` I also made what turned out to be a somewhat unrelated change to add a special region to represent `'empty(U0)`, which we use (somewhat hackily) to indicate well-formedness checks in some parts of the compiler. This fixes #68550. I did some investigation into fixing the error message situation. That's a bit trickier: the existing "nice region error" code around placeholders relies on having better error tracing than NLL currently provides, so that it knows (e.g.) that the constraint arose from applying a trait impl and things like that. I feel like I was hoping *not* to do such fine-grained tracing in NLL, and it seems like we...largely...got away with that. I'm not sure yet if we'll have to add more tracing information or if there is some sort of alternative. It's worth pointing out though that I've not kind of shifted my opinion on whose job it should be to enforce lifetimes: I tend to think we ought to be moving back towards *something like* the leak-check (just not the one we *had*). If we took that approach, it would actually resolve this aspect of the error message problem, because we would be resolving 'higher-ranked errors' in the trait solver itself, and hence we wouldn't have to thread as much causal information back to the region checker. I think it would also help us with removing the leak check while not breaking some of the existing crates out there. Regardless, I think it's worth landing this change, because it was relatively simple and it aligns the set of programs that NLL accepts with those that are accepted by the main region checker, and hence should at least *help* us in migration (though I guess we still also have to resolve the existing crates that rely on leak check for coherence). r? @matthewjasper
2020-04-30Auto merge of #70175 - Amanieu:remove_nlp, r=pnkfelixbors-42/+43
Remove -Z no-landing-pads flag Since #67502, `-Z no-landing-pads` will cause all attempted unwinds to abort since we don't generate a `try` / `catch`. This previously worked because `__rust_try` was located in libpanic_unwind which is always compiled with `-C panic=unwind`, but `__rust_try` is now directly inline into the crate that uses `catch_unwind`. As such, `-Z no-landing-pads` is now mostly useless and people should use `-C panic=abort` instead.
2020-04-29Fix testAmanieu d'Antras-41/+42
2020-04-29Remove -Z no-landing-pads flagAmanieu d'Antras-1/+1
2020-04-28Changed `simplify_match` output query because it had become outdatedFélix Fischer-11/+19
2020-04-28Added MIR const-prop diff tests to show why some assertions now fail at ↵Félix Fischer-0/+421
compile-time
2020-04-28Allow Locals to be propagated into and from, but restricted to their own blockFélix Fischer-16/+148
2020-04-27Added regression test for literal propagation and for scalar pair propagationFélix Fischer-0/+121
2020-04-27Emit basic block ids for statements and terminators in MIR only in -Zverbose ↵Oliver Scherer-3062/+2999
mode
2020-04-26print pointers more compactly when they are too bigRalf Jung-17/+17
2020-04-26sync alloc dump and pointer printingRalf Jung-36/+36
2020-04-26check that `AsRef` and `AsMut` are inlinedBastian Kauschke-0/+139
2020-04-25Rollup merge of #71494 - flip1995:while_let_span, r=petrochenkovDylan DPC-2/+2
Fix span of while (let) expressions after lowering Credit goes to @alex-700 who found this while trying to fix a suggestion in Clippy. While `if`, `try`, `for` and `await` expressions get the span of the original expression when desugared, `while` loops got the span of the scrutinee, which lead to weird code, when building the suggestion, that randomly worked: https://github.com/rust-lang/rust-clippy/pull/5511/files#diff-df4e9d2bf840a5f2e3b580bef73da3bcR106-R108 I'm wondering, if `DesugaringKind` should get a variant `WhileLoop` and instead of using the span of the `ast::ExprKind::While` expr directly, a new span with `self.mark_span_with_reason` should be used, like it is done with `for` loops. There was some fallout, but I think that is acceptable. If not, I need some help to find out where this can be fixed.
2020-04-24Auto merge of #70820 - spastorino:replace-fragile-erroneous-const-sys, r=oli-obkbors-54/+45
Replace fragile erroneous const sys Closes #67191 r? @oli-obk
2020-04-24Rollup merge of #71459 - divergentdave:pointer-offset-0x, r=RalfJungDylan DPC-38/+38
Add leading 0x to offset in Debug fmt of Pointer Currently the `Debug` format for `Pointer` prints its offset in hexadecimal, for example, `alloc38657819+e2` or `alloc35122748+64`. This PR adds a leading `0x` to the offset, in order to make it apparent that it is indeed a hexadecimal number. This came up during discussion of rust-lang/miri#1354. r? @RalfJung
2020-04-24update_testsflip1995-2/+2
2020-04-23Adjust name of never typed const testSantiago Pastorino-4/+5
2020-04-23Bless mir-opt testsSantiago Pastorino-42/+32
2020-04-23Add leading 0x to offset in Debug fmt of PointerDavid Cook-38/+38
2020-04-21update ref testNiko Matsakis-71/+72
2020-04-20Bless 32-bit test outputJonas Schievink-15/+15
2020-04-20Fix codegen and mir-opt testsJonas Schievink-16/+16
Mostly renamed allocations, but I'm not sure about the const prop tests
2020-04-20Auto merge of #71232 - eddyb:print-const-adts, r=oli-obkbors-35/+35
ty/print: pretty-print constant aggregates (arrays, tuples and ADTs). Oddly enough, we don't have any UI tests showing this off in types, only `mir-opt` tests. However, the pretty form should show up in the test output diff of #71018, if this PR is merged first. <hr/> Examples of before/after: |`Option<bool>`| |:-:| |`{transmute(0x01): std::option::Option<bool>}`| | :sparkles: ↓↓↓ :sparkles: | |`std::option::Option::<bool>::Some(true)`| | `RawVec<u32>` | |:-:| | `ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }: alloc::raw_vec::RawVec::<u32>`| | :sparkles: ↓↓↓ :sparkles: | |`alloc::raw_vec::RawVec::<u32> { ptr: std::ptr::Unique::<u32> { pointer: {0x4 as *const u32}, _marker: std::marker::PhantomData::<u32> }, cap: 0usize, alloc: std::alloc::Global }`| <hr/> This PR is a prerequisite for #61486, *sort of*, in that we need to be able to pretty-print values in order to even consider how we might mangle them. We still don't have pretty-printing for constants of reference types, @oli-obk has the necessary support logic in a PR but I didn't want to interfere with that. <hr/> Each commit should be reviewed separately, as I've fixed a couple deficiencies along the way. r? @oli-obk cc @rust-lang/wg-mir-opt @varkor @yodaldevoid
2020-04-17Ignore generator-drop-cleanup on wasm32-bareJonas Schievink-31/+33
2020-04-17Adjust mir-opt test and make it drop somethingJonas Schievink-26/+54
2020-04-17ty/print: pretty-print constant aggregates (arrays, tuples and ADTs).Eduard-Mihai Burtescu-8/+8
2020-04-17mir: pretty-print `Rvalue::Aggregate` correctly.Eduard-Mihai Burtescu-27/+27
2020-04-16reserve variable for empty root regionNiko Matsakis-90/+95
2020-04-15Remove other RvaluesWesley Wiser-133/+90
2020-04-15Add test caseWesley Wiser-0/+80
2020-04-14update 32 bit mir-opt testsBastian Kauschke-31/+119
2020-04-13bless mir opt testsBastian Kauschke-157/+730
2020-04-13Auto merge of #70989 - eddyb:mir-opt-32-pr-ci, r=Mark-Simulacrumbors-1/+77
ci: run mir-opt tests on PR CI also as 32-bit (for `EMIT_MIR_FOR_EACH_BIT_WIDTH`). Background: #69916 and [`src/test/mir-opt/README.md`](https://github.com/rust-lang/rust/blob/master/src/test/mir-opt/README.md): > By default 32 bit and 64 bit targets use the same dump files, which can be problematic in the presence of pointers in constants or other bit width dependent things. In that case you can add > > ``` > // EMIT_MIR_FOR_EACH_BIT_WIDTH > ``` > > to your test, causing separate files to be generated for 32bit and 64bit systems. However, if you change the output of such a test (intentionally or not), or if you add a test and it varies between 32-bit and 64-bit platforms, you have to run this command (for a x64 linux host): `./x.py test --stage 1 --target x86_64-unknown-linux-gnu --target i686-unknown-linux-gnu --bless src/test/mir-opt` Otherwise, bors trying to merge the PR will fail, since we test 32-bit targets there. But we don't on PR CI, which means there's no way the PR author would know (unless they were burnt by this already and know what to look for). This PR resolves that by running `mir-opt` tests for ~~`i686-unknown-linux-gnu`~~, on PR CI. **EDIT**: switched to `armv5te-unknown-linux-gnueabi` to work around LLVM 7 crashes (see https://github.com/rust-lang/compiler-builtins/pull/311#issuecomment-612270089), found during testing. cc @rust-lang/wg-mir-opt @rust-lang/infra
2020-04-11Use write!-style syntax for MIR assert terminatorrobojumper-24/+24
2020-04-11tests: don't use only-64bit in mir-opt tests.Eduard-Mihai Burtescu-1/+77
2020-04-08Add ignore-wasm32-bare to mir-opt tests that need it.Ana-Maria Mihalache-338/+340
2020-04-07Remove old mir-opt test format.Ana-Maria Mihalache-80/+2
2020-04-07Normalize away pairs of line:col numbers.Ana-Maria Mihalache-166/+166
2020-04-07Add EMIT_MIR_FOR_EACH_BIT_WIDTH to tests that need it.Ana-Maria Mihalache-488/+1855
2020-04-07--bless more mir-opt tests.Ana-Maria Mihalache-1013/+2254
2020-04-07--bless all mir-opt tests.Ana-Maria Mihalache-3046/+6572
2020-04-02Remove unused discriminant reads from MIR bodiesWesley Wiser-9/+56
Allow the `SimplifyLocals` pass to remove reads of discriminants if the read is never used.
2020-03-27Auto merge of #69916 - oli-obk:mir_bless, r=eddybbors-138/+795
Enable blessing of mir opt tests cc @rust-lang/wg-mir-opt cc @RalfJung Long overdue, but now you can finally just add a ```rust // EMIT_MIR rustc.function_name.MirPassName.before.mir ``` (or `after.mir` since most of the time you want to know the MIR after a pass). A `--bless` invocation will automatically create the files for you. I suggest we do this for all mir opt tests that have all of the MIR in their source anyway If you use `rustc.function.MirPass.diff` you only get the diff that the MIR pass causes on the MIR. Fixes #67865
2020-03-26Update tests to use llvm_asm!Amanieu d'Antras-11/+11
2020-03-26Enable `--bless`ing of MIR dumpsOliver Scherer-138/+795
2020-03-25Rollup merge of #70319 - lcnr:issue63695, r=eddybDylan DPC-1/+2
correctly normalize constants closes #70317 implements https://github.com/rust-lang/rust/issues/70125#issuecomment-602133708 r? eddyb cc @varkor
2020-03-25run test only on 64bitBastian Kauschke-0/+1