about summary refs log tree commit diff
path: root/src/librustc_codegen_ssa/mir
AgeCommit message (Collapse)AuthorLines
2020-05-06Define UB in float-to-int casts to saturateMark Rousskov-1/+1
- Round to zero, and representable values cast directly. - `NaN` goes to 0 - Values beyond the limits of the type are saturated to the "nearest value" (essentially rounding to zero, in some sense) in the integral type, so e.g. `f32::INFINITY` would go to `{u,i}N::MAX.`
2020-05-03Add `MutatingUseContext::Yield`Dylan MacKenzie-1/+2
...emulating `MutatingUseContext::Call`
2020-05-01Remove deadcode in eval_mir_constant_to_operandSantiago Pastorino-19/+3
2020-04-26Rollup merge of #71392 - ecstatic-morse:body-predecessor-cache-arc, ↵Dylan DPC-1/+1
r=nikomatsakis Don't hold the predecessor cache lock longer than necessary #71044 returns a `LockGuard` with the predecessor cache to callers of `Body::predecessors`. As a result, the lock around the predecessor cache could be held for an arbitrarily long time. This PR uses reference counting for ownership of the predecessor cache, meaning the lock is only ever held within `PredecessorCache::compute`. Checking this API for potential sources of deadlock is much easier now, since we no longer have to consider its consumers, only its internals. This required removing `predecessors_for`, since there is no equivalent to `LockGuard::map` for `Arc` and `Rc`. I believe this could be emulated with `owning_ref::{Arc,Rc}Ref`, but I don't think it's necessary. Also, we continue to return an opaque type from `Body::predecessors` with the lifetime of the `Body`, not `'static`. This depends on #71044. Only the last two commits are new. r? @nikomatsakis
2020-04-23Rename uneval_consts to required_constsSantiago Pastorino-1/+1
2020-04-23Evaluate unevaluated MIR constants in codegen_mirSantiago Pastorino-0/+14
2020-04-22Remove `predecessors_for`Dylan MacKenzie-1/+1
There is no `Arc::map` equivalent to `LockGuard::map`
2020-04-22Auto merge of #71044 - ecstatic-morse:body-predecessor-cache, r=oli-obkbors-15/+14
Remove `BodyAndCache` ...returning to the original approach using interior mutability within `Body`. This simplifies the API at the cost of some uncontended mutex locks when the parallel compiler is enabled. The current API requires you to either have a mutable reference to `Body` (`&mut BodyAndCache`), or to compute the predecessor graph ahead of time by creating a `ReadOnlyBodyAndCache`. This is not a good fit for, e.g., the dataflow framework, which 1. does not mutate the MIR 2. only sometimes needs the predecessor graph (for backward dataflow problems)
2020-04-22Use `Body` everywhereDylan MacKenzie-8/+7
2020-04-22Don't use `*` for deref-coercionDylan MacKenzie-7/+7
2020-04-22Rollup merge of #71401 - spastorino:remove-visit-place-base, r=wesleywiserDylan DPC-1/+1
visit_place_base is just visit_local r? @wesleywiser
2020-04-22Rollup merge of #70970 - eddyb:trait-vs-impl-mismatch, r=oli-obkDylan DPC-0/+1
Detect mistyped associated consts in `Instance::resolve`. *Based on #71049 to prevent redundant/misleading downstream errors.* Fixes #70942 by refusing to resolve an associated `const` if it doesn't have the same type in the `impl` that it does in the `trait` (which we assume had errored, and `delay_span_bug` guards against bugs).
2020-04-21visit_place_base is just visit_localSantiago Pastorino-1/+1
2020-04-19Dogfood more or_patterns in the compilerJosh Stone-20/+27
2020-04-18Detect mistyped associated consts in `Instance::resolve`.Eduard-Mihai Burtescu-0/+1
2020-04-17Rollup merge of #70467 - wesleywiser:invoke-vs-call, r=nagisaDylan DPC-1/+3
Use `call` instead of `invoke` for functions that cannot unwind The `FnAbi` now knows if the function is allowed to unwind. If a function isn't allowed to unwind, we can use a `call` instead of an `invoke`. This resolves an issue when calling LLVM intrinsics which cannot unwind LLVM will generate an error if you attempt to invoke them so we need to ignore cleanup blocks in codegen and generate a call instead. Fixes #69911 r? @eddyb cc @rust-lang/wg-ffi-unwind
2020-04-16mir/interpret: only use `ErrorHandled::Reported` for `ErrorReported`.Eduard-Mihai Burtescu-2/+5
2020-04-15Use `call` instead of `invoke` for functions that cannot unwindWesley Wiser-1/+3
The `FnAbi` now knows if the function is allowed to unwind. If a function isn't allowed to unwind, we can use a `call` instead of an `invoke`. This resolves an issue when calling LLVM intrinsics which cannot unwind LLVM will generate an error if you attempt to invoke them so we need to ignore cleanup blocks in codegen and generate a call instead.
2020-04-05Stop importing int/float modules in librustc_*Linus Färnstrand-2/+0
2020-04-02direct imports for langitem stuffMazdak Farrokhzad-2/+2
2020-04-02nix rustc_target::abi::* reexport in ty::layoutMazdak Farrokhzad-40/+38
2020-04-01Rollup merge of #70616 - anyska:fieldplacement-rename, r=oli-obkDylan DPC-1/+1
rustc_target::abi: rename FieldPlacement to FieldsShape. Originally suggested by @eddyb.
2020-03-31Use Place directly in codegen_place_to_pointer, it's CopySantiago Pastorino-3/+3
2020-03-31Use Place directly in evaluate_array_len, it's CopySantiago Pastorino-2/+2
2020-03-31Use Place directly in codegen_transmute, it's CopySantiago Pastorino-2/+2
2020-03-31Use Place directly on make_return_dest, it's CopySantiago Pastorino-2/+2
2020-03-31Use Place directly on codegen_drop_terminator, it's CopySantiago Pastorino-2/+2
2020-03-31rustc_target::abi: rename FieldPlacement to FieldsShape.Ana-Maria Mihalache-1/+1
2020-03-30rustc -> rustc_middle part 3 (rustfmt)Mazdak Farrokhzad-9/+9
2020-03-30rustc -> rustc_middle part 2Mazdak Farrokhzad-35/+35
2020-03-30Auto merge of #70449 - ecstatic-morse:visit-body, r=oli-obkbors-1/+1
Make `Visitor::visit_body` take a plain `&Body` `ReadOnlyBodyAndCache` has replaced `&Body` in many parts of the code base that don't care about basic block predecessors. This includes the MIR `Visitor` trait, which I suspect resulted in many unnecessary changes in #64736. This reverts part of that PR to reduce the number of places where we need to pass a `ReadOnlyBodyAndCache`. In the long term, we should either give `ReadOnlyBodyAndCache` more ergonomic name and replace all uses of `&mir::Body` with it at the cost of carrying an extra pointer everywhere, or use it only in places that actually need access to the predecessor cache. Perhaps there is an even nicer alternative. r? @Nashenas88
2020-03-29Use `&` to do deref coercion for `ReadOnlyBodyAndCache`Dylan MacKenzie-1/+1
2020-03-29Make `Visitor::visit_body` take a simple `Body`Dylan MacKenzie-1/+1
2020-03-27Rename TyLayout to TyAndLayout.Ana-Maria Mihalache-12/+16
2020-03-26Rename asm! to llvm_asm!Amanieu d'Antras-2/+2
asm! is left as a wrapper around llvm_asm! to maintain compatibility.
2020-03-25make Size::from* methods generic in the integer type they acceptRalf Jung-1/+1
2020-03-23Evaluate repeat expression lengths as late as possibleOliver Scherer-0/+3
2020-03-23Rollup merge of #70249 - lcnr:issue70125, r=eddybMazdak Farrokhzad-24/+19
handle ConstKind::Unresolved after monomorphizing fixes #70125 r? @bjorn3
2020-03-22simplify eval_mir_constantBastian Kauschke-13/+3
2020-03-22handle unevaluated consts after monomophizeBastian Kauschke-21/+26
2020-03-21Rollup merge of #70126 - wesleywiser:fix_miri_ice_neg_zst_enum_discr, ↵Dylan DPC-1/+6
r=RalfJung,eddyb Fix ICE caused by truncating a negative ZST enum discriminant Fixes #70114 r? @oli-obk or @RalfJung
2020-03-21Fix ICE caused by truncating a negative ZST enum discriminantWesley Wiser-1/+6
2020-03-20Rollup merge of #69935 - davidtwco:issue-69925, r=eddybYuki Okushi-6/+11
codegen/mir: support polymorphic `InstanceDef`s cc #69925 This PR modifies the use of `subst_and_normalize_erasing_regions` on parts of the MIR bodies returned from `instance_mir`, so that `InstanceDef::CloneShim` and `InstanceDef::DropGlue` (where there is a type) do not perform substitutions. This avoids double substitutions and enables polymorphic `InstanceDef`s. r? @eddyb cc @nikomatsakis
2020-03-16use direct imports for `rustc::{lint, session}`.Mazdak Farrokhzad-1/+1
2020-03-13Auto merge of #67502 - Mark-Simulacrum:opt-catch, r=Mark-Simulacrumbors-9/+4
Optimize catch_unwind to match C++ try/catch This refactors the implementation of catching unwinds to allow LLVM to inline the "try" closure directly into the happy path, avoiding indirection. This means that the catch_unwind implementation is (after this PR) zero-cost unless a panic is thrown. https://rust.godbolt.org/z/cZcUSB is an example of the current codegen in a simple case. Notably, the codegen is *exactly the same* if `-Cpanic=abort` is passed, which is clearly not great. This PR, on the other hand, generates the following assembly: ```asm # -Cpanic=unwind: push rbx mov ebx,0x2a call QWORD PTR [rip+0x1c53c] # <happy> mov eax,ebx pop rbx ret mov rdi,rax call QWORD PTR [rip+0x1c537] # cleanup function call call QWORD PTR [rip+0x1c539] # <unfortunate> mov ebx,0xd mov eax,ebx pop rbx ret # -Cpanic=abort: push rax call QWORD PTR [rip+0x20a1] # <happy> mov eax,0x2a pop rcx ret ``` Fixes #64224, and resolves #64222.
2020-03-13adjust enum namingRalf Jung-12/+12
2020-03-12rename panic_if_ intrinsics to assert_Ralf Jung-4/+4
2020-03-12codegen/mir: support polymorphic `InstanceDef`sDavid Wood-6/+11
This commit modifies the use of `subst_and_normalize_erasing_regions` on parts of the MIR bodies returned from `instance_mir`, so that `InstanceDef::CloneShim` and `InstanceDef::DropGlue` (where there is a type) do not perform substitutions. This avoids double substitutions and enables polymorphic `InstanceDef`s. Signed-off-by: David Wood <david@davidtw.co>
2020-03-11Rollup merge of #69850 - RalfJung:panic-bounds-check, r=eddybMazdak Farrokhzad-1/+5
panic_bounds_check: use caller_location, like PanicFnLangItem The `PanicFnLangItem` got switched to using `#[caller_location]` at some point, but `PanicBoundsCheckFnLangItem` was kept in the old style. For consistency, switch that one over to use `#[caller_location]` as well. This is also helpful for Miri as it means the `assert_panic` machine hook never needs to know the current `Span`.
2020-03-11Rollup merge of #66059 - RalfJung:panic-on-non-zero, r=eddybMazdak Farrokhzad-35/+92
mem::zeroed/uninit: panic on types that do not permit zero-initialization r? @eddyb @oli-obk Cc https://github.com/rust-lang/rust/issues/62825 Also see [this summary comment](https://github.com/rust-lang/rust/pull/66059#issuecomment-586734747)