about summary refs log tree commit diff
path: root/src/librustc_codegen_llvm/mir
AgeCommit message (Collapse)AuthorLines
2018-10-27Refactor and add `PlaceContext::AscribeUserTy`.David Wood-17/+32
This commit refactors `PlaceContext` to split it into four different smaller enums based on if the context represents a mutating use, non-mutating use, maybe-mutating use or a non-use (this is based on the recommendation from @oli-obk on Zulip[1]). This commit then introduces a `PlaceContext::AscribeUserTy` variant. `StatementKind::AscribeUserTy` is now correctly mapped to `PlaceContext::AscribeUserTy` instead of `PlaceContext::Validate`. `PlaceContext::AscribeUserTy` can also now be correctly categorized as a non-use which fixes an issue with constant promotion in statics after a cast introduces a `AscribeUserTy` statement. [1]: https://rust-lang.zulipchat.com/#narrow/stream/122657-wg-nll/subject/.2355288.20cast.20fails.20to.20promote.20to.20'static/near/136536949
2018-10-26Add the actual chain of projections to `UserTypeProjection`.Felix S. Klock II-2/+5
Update the existing NLL `patterns.rs` test accordingly. includes changes addressing review feedback: * Added example to docs for `UserTypeProjections` illustrating how we build up multiple projections when descending into a pattern with type ascriptions. * Adapted niko's suggested docs for `UserTypeProjection`. * Factored out `projection_ty` from more general `projection_ty_core` (as a drive-by, made its callback an `FnMut`, as I discovered later that I need that). * Add note to docs that `PlaceTy.field_ty(..)` does not normalize its result. * Normalize as we project out `field_ty`.
2018-10-25Rebase fallout in ui outputOliver Schneider-2/+0
2018-10-25Report const eval error inside the queryOliver Schneider-16/+19
2018-10-24Move codegen_llvm::common::ty_fn_sig into rustc::ty::Instance.Masaki Hara-2/+1
2018-10-24Ensure virtual call receiver PassMode.Masaki Hara-0/+2
2018-10-24Implement by-value trait object method call.Masaki Hara-0/+6
2018-10-18Rollup merge of #54933 - ljedrz:cleanup_codegen_llvm/misc, r=varkorkennytm-23/+24
Cleanup the rest of codegen_llvm - improve common patterns - convert string literals with `to_owned` - remove explicit `return`s - whitespace & formatting improvements
2018-10-17rustc: improve E0669 spanLevente Kurusa-4/+4
E0669 refers to a constraint that cannot be coerced into a single LLVM value, unfortunately right now this uses the Span for the entire inline assembly statement, which is less than ideal. This commit preserves the Span from HIR, which lets us emit the error using the Span for the operand itself in MIR. Signed-off-by: Levente Kurusa <lkurusa@acm.org>
2018-10-11Auto merge of #54911 - ljedrz:cleanup_codegen_llvm_top, r=michaelwoeristerbors-6/+6
Cleanup top-level codegen_llvm - improve allocations - improve common patterns - remove explicit returns - fix spelling & grammatical errors - whitespace & formatting improvements
2018-10-10Auto merge of #54747 - levex:inline-asm-bad-operands, r=nagisabors-7/+21
codegen_llvm: verify that inline assembly operands are scalars Another set of inline assembly fixes. This time let's emit an error message when the operand value cannot be coerced into the operand constraint. Two questions: 1) Should I reuse `E0668` which was introduced in #54568 or just use `E0669` as it stands because they do mean different things, but maybe that's not too user-friendly. Just a thought. 2) The `try_fold` returns the operand which failed to be converted into a scalar value, any suggestions on how to use that in the error message? Thanks!
2018-10-10miri engine: basic support for pointer provenance trackingRalf Jung-2/+2
2018-10-09codegen_llvm/misc: whitespace & formatting improvementsljedrz-29/+30
2018-10-08codegen_llvm: whitespace & formatting improvementsljedrz-6/+6
2018-10-06codegen_llvm: verify that inline assembly operands are scalarsLevente Kurusa-7/+21
Otherwise, LLVM translation will fail with a panic. Signed-off-by: Levente Kurusa <lkurusa@acm.org>
2018-10-03Record whether a Call in MIR corresponds to a call in HIRMatthew Jasper-1/+7
2018-10-01Auto merge of #54693 - RalfJung:ctfe-scalar-pair-undef, r=oli-obkbors-11/+7
do not normalize all non-scalar constants to a ConstValue::ScalarPair We still need `ConstValue::ScalarPair` for match handling (matching slices and strings), but that will never see anything `Undef`. For non-fat-ptr `ScalarPair`, just point to the allocation like larger data structures do. Fixes https://github.com/rust-lang/rust/issues/54387 r? @eddyb
2018-09-30adapt to change in Session APIJorge Aparicio-1/+1
2018-09-30move our check to reuse a previous computationJorge Aparicio-20/+21
2018-09-30improve panic messageJorge Aparicio-8/+6
2018-09-30use is_uninhabited in more placesJorge Aparicio-3/+3
2018-09-30panic when instantiating an uninhabited type via mem::{uninitialized,zeroed}Jorge Aparicio-0/+49
2018-09-30do not normalize non-scalar constants to a ConstValue::ScalarPairRalf Jung-11/+7
2018-09-29Revert "Auto merge of #53508 - japaric:maybe-uninit, r=RalfJung"Ralf Jung-51/+3
This reverts commit c6e3d7fa3113aaa64602507f39d4627c427742ff, reversing changes made to 4591a245c7eec9f70d668982b1383cd2a6854af5.
2018-09-28Auto merge of #54568 - levex:issue-54130, r=nagisabors-1/+5
codegen_llvm: check inline assembly constraints with LLVM ---%<--- Hey all, As issue #54130 highlights, constraints are not checked and passing bad constraints to LLVM can crash it since a `Verify()` call is placed inside an assertion (see: `src/llvm/lib/IR/InlineAsm.cpp:39`). As this is my first PR to the Rust compiler (woot! :tada:), there might be better ways of achieving this result. In particular, I am not too happy about generating an error in codegen; it would be much nicer if we did it earlier. However, @rkruppe [noted on IRC](https://botbot.me/mozilla/rustc/2018-09-25/?msg=104791581&page=1) that this should be fine for an unstable feature and a much better solution than the _status quo_, which is an ICE. Thanks! --->%--- LLVM provides a way of checking whether the constraints and the actual inline assembly make sense. This commit introduces a check before emitting code for the inline assembly. If LLVM rejects the inline assembly (or its constraints), then the compiler emits an error E0668 ("malformed inline assembly"). Fixes: #54130 Signed-off-by: Levente Kurusa \<lkurusa@acm.org\>
2018-09-26fixup! codegen_llvm: check inline assembly constraints with LLVMLevente Kurusa-1/+2
2018-09-25codegen_llvm: check inline assembly constraints with LLVMLevente Kurusa-1/+4
LLVM provides a way of checking whether the constraints and the actual inline assembly make sense. This commit introduces a check before emitting code for the inline assembly. If LLVM rejects the inline assembly (or its constraints), then the compiler emits an error E0668 ("malformed inline assembly"). Signed-off-by: Levente Kurusa <lkurusa@acm.org>
2018-09-24Rely only on base alignment and offset for computing field alignmentColin Pronovost-4/+1
Fix #54028
2018-09-23Auto merge of #54380 - RalfJung:miri-snapshot, r=eddybbors-1/+1
move CTFE engine snapshot state out of miri engine into CTFE machine instance It still lives in the `interpret` module as it needs access to all sorts of private stuff. Also rename a thing to make @eddyb happy :D The goal was not to change any behavior.
2018-09-22Auto merge of #53508 - japaric:maybe-uninit, r=RalfJungbors-3/+51
Implement `MaybeUninit` This PR: - Adds `MaybeUninit` (see #53491) to `{core,std}::mem`. - Makes `mem::{uninitialized,zeroed}` panic when they are used to instantiate an uninhabited type. - Does *not* deprecate `mem::{uninitialized,zeroed}` just yet. As per https://github.com/rust-lang/rust/issues/53491#issuecomment-414147666, we should not deprecate them until `MaybeUninit` is stabilized. - It replaces uses of `mem::{uninitialized,zeroed}` in core and alloc with `MaybeUninit`. There are still several instances of `mem::{uninitialized,zeroed}` in `std` that *this* PR doesn't address. r? @RalfJung cc @eddyb you may want to look at the new panicking logic
2018-09-22move our check to reuse a previous computationJorge Aparicio-20/+21
2018-09-22improve panic messageJorge Aparicio-8/+6
2018-09-22use is_uninhabited in more placesJorge Aparicio-3/+3
2018-09-22adapt to change in Session APIJorge Aparicio-1/+1
2018-09-22panic when instantiating an uninhabited type via mem::{uninitialized,zeroed}Jorge Aparicio-0/+49
2018-09-20rename evaluator -> interpreter to make eddyb happyRalf Jung-1/+1
2018-09-18Refactor 'ReadForMatch' into 'FakeRead' and add the cause of the fake readRemy Rakic-1/+1
2018-09-18Merge indexed_set.rs into bitvec.rs, and rename it bit_set.rs.Nicholas Nethercote-7/+7
Currently we have two files implementing bitsets (and 2D bit matrices). This commit combines them into one, taking the best features from each. This involves renaming a lot of things. The high level changes are as follows. - bitvec.rs --> bit_set.rs - indexed_set.rs --> (removed) - BitArray + IdxSet --> BitSet (merged, see below) - BitVector --> GrowableBitSet - {,Sparse,Hybrid}IdxSet --> {,Sparse,Hybrid}BitSet - BitMatrix --> BitMatrix - SparseBitMatrix --> SparseBitMatrix The changes within the bitset types themselves are as follows. ``` OLD OLD NEW BitArray<C> IdxSet<T> BitSet<T> -------- ------ ------ grow - grow new - (remove) new_empty new_empty new_empty new_filled new_filled new_filled - to_hybrid to_hybrid clear clear clear set_up_to set_up_to set_up_to clear_above - clear_above count - count contains(T) contains(&T) contains(T) contains_all - superset is_empty - is_empty insert(T) add(&T) insert(T) insert_all - insert_all() remove(T) remove(&T) remove(T) words words words words_mut words_mut words_mut - overwrite overwrite merge union union - subtract subtract - intersect intersect iter iter iter ``` In general, when choosing names I went with: - names that are more obvious (e.g. `BitSet` over `IdxSet`). - names that are more like the Rust libraries (e.g. `T` over `C`, `insert` over `add`); - names that are more set-like (e.g. `union` over `merge`, `superset` over `contains_all`, `domain_size` over `num_bits`). Also, using `T` for index arguments seems more sensible than `&T` -- even though the latter is standard in Rust collection types -- because indices are always copyable. It also results in fewer `&` and `*` sigils in practice.
2018-09-12Merge branch 'master' into kenta7777#53719kenta7777-1/+1
2018-09-11renamed is_nil to is_unitkenta7777-2/+2
2018-09-11Revert "renamed is_nil to is_unit"kenta7777-2/+2
This reverts commit 6f685ffad42a2d12dd1fad5ccb0471e7fa260826.
2018-09-10add the `AscribeUserType` statement kindNiko Matsakis-1/+1
Make it have the semantics of subtype.
2018-09-10renamed is_nil to is_unitkenta7777-2/+2
2018-09-09Auto merge of #53998 - eddyb:issue-53728, r=oli-obkbors-3/+6
rustc_codegen_llvm: don't assume offsets are always aligned. Fixes #53728 by taking into account not just overall type alignment and the field's alignment when determining whether a field is aligned or not ("packed"), but also the field's offset within the type. Previously, rustc assumed that the offset was always at least as aligned as `min(struct.align, field.align)`. However, there's no real reason to have that assumption, and it obviously can't always be true after we implement `#[repr(align(N), pack(K))]`. There's also a case today where that assumption is not true, involving niche discriminants in enums: Suppose that we have the code in #53728: ```Rust #[repr(u16)] enum DeviceKind { Nil = 0, } #[repr(packed)] struct DeviceInfo { endianness: u8, device_kind: DeviceKind, } struct Wrapper { device_info: DeviceInfo, data: u32 } ``` Observe the layout of `Option<Wrapper>`. It has an alignment of 4 because of the `u32`. `device_info.device_kind` is a good niche field to use, which means the enum ends up with this layout: ``` size = 8 align = 4 fields = [ { offset=1, type=u16 } // discriminant, .<Some>.device_info.device_kind ] ``` And here we have an discriminant with alignment 2 (`u16`) but offset 1.
2018-09-07make field always private, add `From` implsNiko Matsakis-3/+1
2018-09-06rustc_codegen_llvm: don't assume offsets are always aligned.Eduard-Mihai Burtescu-3/+6
2018-08-27Miri Memory WorkRalf Jung-4/+4
* Unify the two maps in memory to store the allocation and its kind together. * Share the handling of statics between CTFE and miri: The miri engine always uses "lazy" `AllocType::Static` when encountering a static. Acessing that static invokes CTFE (no matter the machine). The machine only has any influence when writing to a static, which CTFE outright rejects (but miri makes a copy-on-write). * Add an `AllocId` to by-ref consts so miri can use them as operands without making copies. * Move responsibilities around for the `eval_fn_call` machine hook: The hook just has to find the MIR (or entirely take care of everything); pushing the new stack frame is taken care of by the miri engine. * Expose the intrinsics and lang items implemented by CTFE so miri does not have to reimplement them.
2018-08-24support user-given types in adtsNiko Matsakis-1/+1
2018-08-22Remove Ty prefix from Ty{Bool|Char|Int|Uint|Float|Str}varkor-38/+38
2018-08-22Remove Ty prefix from Ty{Foreign|Param}varkor-1/+1