summary refs log tree commit diff
path: root/compiler/rustc_middle/src/mir
AgeCommit message (Collapse)AuthorLines
2021-05-03Remove assert_matches usersMark Rousskov-1/+1
2021-03-18Remove unwrap_none/expect_none from compiler/.Mara Bos-1/+1
2021-03-15Do not expose fallible `to_int` operation on `Scalar`.Oli Scherer-18/+16
Any use of it has been shown to be a bug in the past.
2021-03-15s/ConstantSource/ConstantKind/Oli Scherer-29/+21
2021-03-12Visit `mir::Constant::user_ty` for completeness.Oli Scherer-2/+2
It's not necessary yet, but it may become necessary with things like lazy normalization.
2021-03-12Replace a custom lift method with a Lift implOli Scherer-4/+7
2021-03-12Prepare mir::Constant for ty::Const only supporting valtreesOli Scherer-11/+164
2021-03-12Add `ty` helper function for mir constantsOli Scherer-0/+3
This is in preparation of the `literal` field becoming an enum that distinguishes between type level constants and runtime constants
2021-03-12Add convenience conversion methods for ScalarIntOli Scherer-8/+23
2021-03-12Add fallible Scalar to ScalarInt conversion methodOli Scherer-13/+15
2021-03-12Implement valtreeOli Scherer-1/+1
valtree is a version of constants that is inherently safe to be used within types. This is in contrast to ty::Const which can have different representations of the same value. These representation differences can show up in hashing or equality comparisons, breaking type equality of otherwise equal types. valtrees do not have this problem.
2021-03-10Rollup merge of #79208 - LeSeulArtichaut:stable-unsafe_op_in_unsafe_fn, ↵Yuki Okushi-2/+0
r=nikomatsakis Stabilize `unsafe_op_in_unsafe_fn` lint This makes it possible to override the level of the `unsafe_op_in_unsafe_fn`, as proposed in https://github.com/rust-lang/rust/issues/71668#issuecomment-729770896. Tracking issue: #71668 r? ```@nikomatsakis``` cc ```@SimonSapin``` ```@RalfJung``` # Stabilization report This is a stabilization report for `#![feature(unsafe_block_in_unsafe_fn)]`. ## Summary Currently, the body of unsafe functions is an unsafe block, i.e. you can perform unsafe operations inside. The `unsafe_op_in_unsafe_fn` lint, stabilized here, can be used to change this behavior, so performing unsafe operations in unsafe functions requires an unsafe block. For now, the lint is allow-by-default, which means that this PR does not change anything without overriding the lint level. For more information, see [RFC 2585](https://github.com/rust-lang/rfcs/blob/master/text/2585-unsafe-block-in-unsafe-fn.md) ### Example ```rust // An `unsafe fn` for demonstration purposes. // Calling this is an unsafe operation. unsafe fn unsf() {} // #[allow(unsafe_op_in_unsafe_fn)] by default, // the behavior of `unsafe fn` is unchanged unsafe fn allowed() { // Here, no `unsafe` block is needed to // perform unsafe operations... unsf(); // ...and any `unsafe` block is considered // unused and is warned on by the compiler. unsafe { unsf(); } } #[warn(unsafe_op_in_unsafe_fn)] unsafe fn warned() { // Removing this `unsafe` block will // cause the compiler to emit a warning. // (Also, no "unused unsafe" warning will be emitted here.) unsafe { unsf(); } } #[deny(unsafe_op_in_unsafe_fn)] unsafe fn denied() { // Removing this `unsafe` block will // cause a compilation error. // (Also, no "unused unsafe" warning will be emitted here.) unsafe { unsf(); } } ```
2021-03-09Switch to changing cp_non_overlap in tformkadmin-1/+1
It was suggested to lower this in MIR instead of ssa, so do that instead.
2021-03-09Update craneliftkadmin-13/+10
2021-03-09Update match brancheskadmin-11/+5
This updates all places where match branches check on StatementKind or UseContext. This doesn't properly implement them, but adds TODOs where they are, and also adds some best guesses to what they should be in some cases.
2021-03-09Update fmt and use of memcpykadmin-1/+1
I'm still not totally sure if this is the right way to implement the memcpy, but that portion compiles correctly now. Now to fix the compile errors everywhere else :).
2021-03-09Impl StatementKind::CopyNonOverlappingkadmin-0/+38
2021-03-09Rollup merge of #82841 - hvdijk:x32, r=joshtriplettMara Bos-9/+9
Change x64 size checks to not apply to x32. Rust contains various size checks conditional on target_arch = "x86_64", but these checks were never intended to apply to x86_64-unknown-linux-gnux32. Add target_pointer_width = "64" to the conditions.
2021-03-08Auto merge of #82727 - oli-obk:shrinkmem, r=pnkfelixbors-12/+26
Test the effect of shrinking the size of Rvalue by 16 bytes r? `@ghost`
2021-03-06Change x64 size checks to not apply to x32.Harald van Dijk-9/+9
Rust contains various size checks conditional on target_arch = "x86_64", but these checks were never intended to apply to x86_64-unknown-linux-gnux32. Add target_pointer_width = "64" to the conditions.
2021-03-05Shrink the size of Rvalue by 16 bytesOli Scherer-13/+15
2021-03-04Remove a dead code pathOli Scherer-12/+0
2021-03-03Check the sizes of Operand, Rvalue, AggregateKind and PlaceOli Scherer-0/+12
2021-03-01Box generator-related Body fieldsDániel Buga-25/+53
2021-02-26Miscellaneous inlining improvementsTomasz Miąsko-0/+10
Inline a few small and hot functions.
2021-02-25Auto merge of #82338 - RalfJung:interp-error-allocs, r=oli-obkbors-15/+10
all InterpError allocate now, so adjust alloc-error-check Cc https://github.com/rust-lang/rust/pull/82116#discussion_r578310770 r? `@oli-obk`
2021-02-24Auto merge of #80475 - simonvandel:fix-77355, r=oli-obkbors-1/+24
New mir-opt pass to simplify gotos with const values (reopening #77486) Reopening PR #77486 Fixes #77355 This pass optimizes the following sequence ```rust bb2: { _2 = const true; goto -> bb3; } bb3: { switchInt(_2) -> [false: bb4, otherwise: bb5]; } ``` into ```rust bb2: { _2 = const true; goto -> bb5; } ```
2021-02-23Rollup merge of #82091 - henryboisdequin:use-place-ref-more, r=RalfJungDylan DPC-8/+7
use PlaceRef abstractions more consistently Addresses this [comment](https://github.com/rust-lang/rust/pull/80865/files#r558978715) Associated issue: #80647 r? ```@RalfJung```
2021-02-22New mir-opt pass to simplify gotos with const valuesSimon Vandel Sillesen-1/+24
Fixes #77355
2021-02-22Auto merge of #77551 - simonvandel:extend-simplify-branch-same, r=oli-obkbors-22/+43
MIR-OPT: Pass to deduplicate blocks This pass finds basic blocks that are completely equal, and replaces all uses with just one of them. ```bash $ RUSTC_LOG=rustc_mir::transform::deduplicate_blocks ./x.py build --stage 2 | grep "SUCCESS: Replacing: " > log ... $ cat log | wc -l 23875 ```
2021-02-21New pass to deduplicate blocksSimon Vandel Sillesen-22/+43
2021-02-21remove redundant return value Ok(()) of clear_relocations()Matthias Krüger-10/+3
2021-02-20all InterpError allocate now, so adjust alloc-error-checkRalf Jung-15/+10
2021-02-20make `super_projection` take a `PlaceRef`Henry Boisdequin-5/+5
2021-02-18Stabilize `unsafe_op_in_unsafe_fn` lintLeSeulArtichaut-2/+0
2021-02-17Reduce size of InterpErrorInfo to 8 bytesTomasz Miąsko-6/+22
2021-02-16Auto merge of #81611 - cjgillot:meowner, r=estebankbors-9/+8
Only store a LocalDefId in some HIR nodes Some HIR nodes are guaranteed to be HIR owners: Item, TraitItem, ImplItem, ForeignItem and MacroDef. As a consequence, we do not need to store the `HirId`'s `local_id`, and we can directly store a `LocalDefId`. This allows to avoid a bit of the dance with `tcx.hir().local_def_id` and `tcx.hir().local_def_id_to_hir_id` mappings.
2021-02-16make `visit_projection` take a `PlaceRef`Henry Boisdequin-4/+3
2021-02-16update formatingHenry Boisdequin-2/+4
2021-02-15Only store a LocalDefId in hir::Item.Camille GILLOT-2/+1
Items are guaranteed to be HIR owner.
2021-02-15Use an ItemId inside mir::GlobalAsm.Camille GILLOT-8/+8
2021-02-14param_env debugs are instrumental to rustc's successEllen-1/+1
2021-02-14use option<PlaceRef<'tcx>> to clean up mir code a littleHenry Boisdequin-4/+2
2021-02-13debug!("paramenv={}paramenv={}paramenv={}paramenv={}")Ellen-0/+1
2021-02-02Rollup merge of #81665 - jacob-hughes:mir_doc_fix, r=estebankJack Huey-1/+1
Fix out of date `Scalar` documentation Scalars can represent integers up to `u128`, but the docs state otherwise.
2021-02-02Fix out of date `Scalar` documentationJake Hughes-1/+1
Scalars can represent integers up to u128, but the docs state otherwise.
2021-02-02Bump rustfmt versionMark Rousskov-4/+2
Also switches on formatting of the mir build module
2021-01-30Rollup merge of #80959 - jhpratt:unsigned_abs-stabilization, r=m-ou-seYuki Okushi-11/+2
Stabilize `unsigned_abs` Resolves #74913. This PR stabilizes the `i*::unsigned_abs()` method, which returns the absolute value of an integer _as its unsigned equivalent_. This has the advantage that it does not overflow on `i*::MIN`. I have gone ahead and used this in a couple locations throughout the repository.
2021-01-26Auto merge of #80692 - Aaron1011:feature/query-result-debug, r=estebankbors-5/+6
Enforce that query results implement Debug Currently, we require that query keys implement `Debug`, but we do not do the same for query values. This can make incremental compilation bugs difficult to debug - there isn't a good place to print out the result loaded from disk. This PR adds `Debug` bounds to several query-related functions, allowing us to debug-print the query value when an 'unstable fingerprint' error occurs. This required adding `#[derive(Debug)]` to a fairly large number of types - hopefully, this doesn't have much of an impact on compiler bootstrapping times.
2021-01-23Rollup merge of #81243 - osa1:fix_80742_2, r=RalfJungJonas Schievink-0/+3
mir: Improve size_of handling when arg is unsized As discussed on Zulip with `@RalfJung.`