| Age | Commit message (Collapse) | Author | Lines | |
|---|---|---|---|---|
| 2020-07-25 | The const propagator cannot trace references. | Oliver Scherer | -10/+36 | |
| Thus we avoid propagation of a local the moment we encounter references to it. | ||||
| 2020-06-26 | Disable the `SimplifyArmIdentity` pass on beta | Wesley Wiser | -1/+5 | |
| This pass is buggy so I'm disabling it to fix a stable-to-beta regression. Related to #73223 | ||||
| 2020-06-13 | Revert "Auto merge of #71956 - ↵ | Mark Rousskov | -127/+136 | |
| ecstatic-morse:remove-requires-storage-analysis, r=tmandry" This reverts commit 458a3e76294fd859fb037f425404180c91e14767, reversing changes made to d9417b385145af1cabd0be8a95c65075d2fc30ff. | ||||
| 2020-06-01 | test miri-unleash TLS accesses | Ralf Jung | -10/+1 | |
| 2020-06-01 | Auto merge of #71192 - oli-obk:eager_alloc_id_canonicalization, r=wesleywiser | bors | -6/+15 | |
| Make TLS accesses explicit in MIR r? @rust-lang/wg-mir-opt cc @RalfJung @vakaras for miri thread locals cc @bjorn3 for cranelift fixes #70685 | ||||
| 2020-05-30 | Make TLS accesses explicit in MIR | Oliver Scherer | -6/+15 | |
| 2020-05-30 | more `LocalDefId`s | Bastian Kauschke | -8/+9 | |
| 2020-05-29 | Rollup merge of #71862 - LeSeulArtichaut:unsafe-block-in-unsafe-fn, ↵ | Ralf Jung | -23/+117 | |
| r=nikomatsakis Implement RFC 2585: unsafe blocks in unsafe fn Tracking issue: #71668 r? @RalfJung cc @nikomatsakis | ||||
| 2020-05-28 | remove redundant `mk_const` | Bastian Kauschke | -1/+1 | |
| 2020-05-28 | Auto merge of #72494 - lcnr:predicate-cleanup, r=nikomatsakis | bors | -12/+12 | |
| Pass more `Copy` types by value. There are a lot of locations where we pass `&T where T: Copy` by reference, which should both be slightly less performant and less readable IMO. This PR currently consists of three fairly self contained commits: - passes `ty::Predicate` by value and stops depending on `AsRef<ty::Predicate>`. - changes `<&List<_>>::into_iter` to iterate over the elements by value. This would break `List`s of non copy types. But as the only list constructor requires `T` to be copy anyways, I think the improved readability is worth this potential future restriction. - passes `mir::PlaceElem` by value. Mir currently has quite a few copy types which are passed by reference, e.g. `Local`. As I don't have a lot of experience working with MIR, I mostly did this to get some feedback from people who use MIR more frequently - tries to reuse `ty::Predicate` in case it did not change in some places, which should hopefully fix the regression caused by #72055 r? @nikomatsakis for the first commit, which continues the work of #72055 and makes adding `PredicateKind::ForAll` slightly more pleasant. Feel free to reassign though | ||||
| 2020-05-27 | Add explanation about taking the minimum of the two lints | LeSeulArtichaut | -0/+11 | |
| 2020-05-27 | Fix wrong conflict resolution | LeSeulArtichaut | -7/+1 | |
| 2020-05-27 | Use the lowest of `unsafe_op_in_unsafe_fn` and `safe_borrow_packed` for ↵ | LeSeulArtichaut | -5/+28 | |
| packed borrows in unsafe fns | ||||
| 2020-05-27 | Fix inverted `if` condition | LeSeulArtichaut | -1/+1 | |
| 2020-05-27 | Apply suggestions from code review | LeSeulArtichaut | -23/+44 | |
| 2020-05-27 | Implement RFC 2585 | LeSeulArtichaut | -9/+54 | |
| 2020-05-26 | Rollup merge of #72401 - ecstatic-morse:issue-72394, r=eddyb | Dylan DPC | -2/+2 | |
| Use correct function for detecting `const fn` in unsafety checking Resolves #72394. | ||||
| 2020-05-26 | Rollup merge of #72270 - RalfJung:lint-ref-to-packed, r=oli-obk | Dylan DPC | -1/+71 | |
| add a lint against references to packed fields Creating a reference to an insufficiently aligned packed field is UB and should be disallowed, both inside and outside of `unsafe` blocks. However, currently there is no stable alternative (https://github.com/rust-lang/rust/issues/64490) so all we do right now is have a future incompatibility warning when doing this outside `unsafe` (https://github.com/rust-lang/rust/issues/46043). This adds an allow-by-default lint. @retep998 suggested this can help early adopters avoid issues. It also means we can then do a crater run where this is deny-by-default as suggested by @joshtriplett. I guess the main thing to bikeshed is the lint name. I am not particularly happy with "packed_references" as it sounds like the packed field has reference type. I chose this because it is similar to "safe_packed_borrows". What about "reference_to_packed" or "unaligned_reference" or so? | ||||
| 2020-05-26 | Auto merge of #72093 - jonas-schievink:unmut, r=oli-obk | bors | -8/+110 | |
| Avoid `Operand::Copy` with `&mut T` This is generally unsound to do, as the copied type is assumed to implement `Copy`. Closes https://github.com/rust-lang/rust/issues/46420 | ||||
| 2020-05-25 | Rollup merge of #72451 - ecstatic-morse:nrvo-type-mismatch, r=matthewjasper | Dylan DPC | -12/+6 | |
| Perform MIR NRVO even if types don't match This is the most straightforward way to resolve #72428, but it could cause problems in codegen since the type of `_0` may no longer match the return type of the body. | ||||
| 2020-05-25 | Always validate MIR after optimizing | Jonas Schievink | -0/+5 | |
| 2020-05-25 | Add a small MIR validation pass | Jonas Schievink | -1/+93 | |
| 2020-05-25 | Avoid `Operand::Copy` with `&mut T` | Jonas Schievink | -7/+12 | |
| 2020-05-25 | rename lint | Ralf Jung | -4/+4 | |
| 2020-05-25 | add a lint against references to packed fields | Ralf Jung | -1/+71 | |
| 2020-05-25 | Auto merge of #72520 - jonas-schievink:cleanup-userty, r=matthewjasper | bors | -0/+4 | |
| Clear MIR local type annotations after borrowck | ||||
| 2020-05-24 | Clear MIR local type annotations after borrowck | Jonas Schievink | -0/+4 | |
| 2020-05-23 | fix discriminant type in generator transform | Ralf Jung | -1/+1 | |
| 2020-05-23 | take mir::PlaceElem by value | Bastian Kauschke | -10/+10 | |
| 2020-05-23 | iterate List by value | Bastian Kauschke | -2/+2 | |
| 2020-05-21 | Perform MIR NRVO even if types don't match | Dylan MacKenzie | -12/+6 | |
| 2020-05-22 | Auto merge of #71956 - ecstatic-morse:remove-requires-storage-analysis, ↵ | bors | -136/+127 | |
| r=tmandry Clean up logic around live locals in generator analysis Resolves #69902. Requires #71893. I've found it difficult to make changes in the logic around live locals in `generator/transform.rs`. It uses a custom dataflow analysis, `MaybeRequiresStorage`, that AFAICT computes whether a local is either initialized or borrowed. That analysis is using `before` effects, which we should try to avoid if possible because they are harder to reason about than ones only using the unprefixed effects. @pnkfelix has suggested removing "before" effects entirely to simplify the dataflow framework, which I might pursue someday. This PR replaces `MaybeRequiresStorage` with a combination of the existing `MaybeBorrowedLocals` and a new `MaybeInitializedLocals`. `MaybeInitializedLocals` is just `MaybeInitializedPlaces` with a coarser resolution: it works on whole locals instead of move paths. As a result, I was able to simplify the logic in `compute_storage_conflicts` and `locals_live_across_suspend_points`. This is not exactly equivalent to the old logic; some generators are now smaller than before. I believe this was because the old logic was too conservative, but I'm not as familiar with the constraints as the original implementers were, so I could be wrong. For example, I don't see a reason the size of the `mixed_sizes` future couldn't be 5K. It went from 7K to 6K in this PR. r? @jonas-schievink @tmandry | ||||
| 2020-05-21 | Rollup merge of #72055 - lcnr:predicate-kind, r=nikomatsakis | Ralf Jung | -13/+15 | |
| Intern predicates Implements the first step of https://github.com/rust-lang/compiler-team/issues/285 Renames `ty::Predicate` to `ty::PredicateKind`, which is now interned. To ease the transition, `ty::Predicate` is now a struct containing a reference to `ty::PredicateKind`. r? @ghost | ||||
| 2020-05-21 | Auto merge of #72205 - ecstatic-morse:nrvo, r=oli-obk | bors | -0/+240 | |
| Dumb NRVO This is a very simple version of an NRVO pass, which scans backwards from the `return` terminator to see if there is an an assignment like `_0 = _1`. If a basic block with two or more predecessors is encountered during this scan without first seeing an assignment to the return place, we bail out. This avoids running a full "reaching definitions" dataflow analysis. I wanted to see how much `rustc` would benefit from even a very limited version of this optimization. We should be able to use this as a point of comparison for more advanced versions that are based on live ranges. r? @ghost | ||||
| 2020-05-20 | Bail out if new return place has different type than old | Dylan MacKenzie | -1/+12 | |
| 2020-05-20 | Use `is_const_fn_raw` when unsafety checking | Dylan MacKenzie | -2/+2 | |
| 2020-05-20 | change `Predicate::kind` to return a reference | Bastian Kauschke | -1/+1 | |
| 2020-05-20 | introduce newtype'd `Predicate<'tcx>` | Bastian Kauschke | -2/+2 | |
| 2020-05-20 | rename `Predicate` to `PredicateKind`, introduce alias | Bastian Kauschke | -11/+13 | |
| 2020-05-19 | Document why we don't look at storage liveness | Dylan MacKenzie | -0/+9 | |
| ...when determining what locals are live. A local cannot be borrowed before it is `storage_live` and `MaybeBorrowedLocals` already invalidates borrows on `StorageDead`. Likewise, a local cannot be initialized before it is marked StorageLive and is marked as uninitialized after `StorageDead`. | ||||
| 2020-05-19 | Look for storage conflicts before terminator effect | Dylan MacKenzie | -5/+6 | |
| 2020-05-19 | Add comment for strange conditional | Dylan MacKenzie | -0/+1 | |
| 2020-05-19 | Add comment explaining the extra `record_conflicts` | Dylan MacKenzie | -0/+4 | |
| 2020-05-19 | Clean up generator live locals analysis | Dylan MacKenzie | -137/+113 | |
| Instead of using a bespoke dataflow analysis, `MaybeRequiresStorage`, for computing locals that need to be stored across yield points and that have conflicting storage, use a combination of simple, generally applicable dataflow analyses. In this case, the formula for locals that are live at a yield point is: live_across_yield := (live & init) | (!movable & borrowed) and the formula for locals that require storage (and thus may conflict with others) at a given point is: requires_storage := init | borrowed `init` is `MaybeInitializedLocals`, a direct equivalent of `MaybeInitializedPlaces` that works only on whole `Local`s. `borrowed` and `live` are the pre-existing `MaybeBorrowedLocals` and `MaybeLiveLocals` analyses respectively. | ||||
| 2020-05-19 | Auto merge of #69171 - Amanieu:new-asm, r=nagisa,nikomatsakis | bors | -19/+90 | |
| Implement new asm! syntax from RFC 2850 This PR implements the new `asm!` syntax proposed in https://github.com/rust-lang/rfcs/pull/2850. # Design A large part of this PR revolves around taking an `asm!` macro invocation and plumbing it through all of the compiler layers down to LLVM codegen. Throughout the various stages, an `InlineAsm` generally consists of 3 components: - The template string, which is stored as an array of `InlineAsmTemplatePiece`. Each piece represents either a literal or a placeholder for an operand (just like format strings). ```rust pub enum InlineAsmTemplatePiece { String(String), Placeholder { operand_idx: usize, modifier: Option<char>, span: Span }, } ``` - The list of operands to the `asm!` (`in`, `[late]out`, `in[late]out`, `sym`, `const`). These are represented differently at each stage of lowering, but follow a common pattern: - `in`, `out` and `inout` all have an associated register class (`reg`) or explicit register (`"eax"`). - `inout` has 2 forms: one with a single expression that is both read from and written to, and one with two separate expressions for the input and output parts. - `out` and `inout` have a `late` flag (`lateout` / `inlateout`) to indicate that the register allocator is allowed to reuse an input register for this output. - `out` and the split variant of `inout` allow `_` to be specified for an output, which means that the output is discarded. This is used to allocate scratch registers for assembly code. - `sym` is a bit special since it only accepts a path expression, which must point to a `static` or a `fn`. - The options set at the end of the `asm!` macro. The only one that is particularly of interest to rustc is `NORETURN` which makes `asm!` return `!` instead of `()`. ```rust bitflags::bitflags! { pub struct InlineAsmOptions: u8 { const PURE = 1 << 0; const NOMEM = 1 << 1; const READONLY = 1 << 2; const PRESERVES_FLAGS = 1 << 3; const NORETURN = 1 << 4; const NOSTACK = 1 << 5; } } ``` ## AST `InlineAsm` is represented as an expression in the AST: ```rust pub struct InlineAsm { pub template: Vec<InlineAsmTemplatePiece>, pub operands: Vec<(InlineAsmOperand, Span)>, pub options: InlineAsmOptions, } pub enum InlineAsmRegOrRegClass { Reg(Symbol), RegClass(Symbol), } pub enum InlineAsmOperand { In { reg: InlineAsmRegOrRegClass, expr: P<Expr>, }, Out { reg: InlineAsmRegOrRegClass, late: bool, expr: Option<P<Expr>>, }, InOut { reg: InlineAsmRegOrRegClass, late: bool, expr: P<Expr>, }, SplitInOut { reg: InlineAsmRegOrRegClass, late: bool, in_expr: P<Expr>, out_expr: Option<P<Expr>>, }, Const { expr: P<Expr>, }, Sym { expr: P<Expr>, }, } ``` The `asm!` macro is implemented in librustc_builtin_macros and outputs an `InlineAsm` AST node. The template string is parsed using libfmt_macros, positional and named operands are resolved to explicit operand indicies. Since target information is not available to macro invocations, validation of the registers and register classes is deferred to AST lowering. ## HIR `InlineAsm` is represented as an expression in the HIR: ```rust pub struct InlineAsm<'hir> { pub template: &'hir [InlineAsmTemplatePiece], pub operands: &'hir [InlineAsmOperand<'hir>], pub options: InlineAsmOptions, } pub enum InlineAsmRegOrRegClass { Reg(InlineAsmReg), RegClass(InlineAsmRegClass), } pub enum InlineAsmOperand<'hir> { In { reg: InlineAsmRegOrRegClass, expr: Expr<'hir>, }, Out { reg: InlineAsmRegOrRegClass, late: bool, expr: Option<Expr<'hir>>, }, InOut { reg: InlineAsmRegOrRegClass, late: bool, expr: Expr<'hir>, }, SplitInOut { reg: InlineAsmRegOrRegClass, late: bool, in_expr: Expr<'hir>, out_expr: Option<Expr<'hir>>, }, Const { expr: Expr<'hir>, }, Sym { expr: Expr<'hir>, }, } ``` AST lowering is where `InlineAsmRegOrRegClass` is converted from `Symbol`s to an actual register or register class. If any modifiers are specified for a template string placeholder, these are validated against the set allowed for that operand type. Finally, explicit registers for inputs and outputs are checked for conflicts (same register used for different operands). ## Type checking Each register class has a whitelist of types that it may be used with. After the types of all operands have been determined, the `intrinsicck` pass will check that these types are in the whitelist. It also checks that split `inout` operands have compatible types and that `const` operands are integers or floats. Suggestions are emitted where needed if a template modifier should be used for an operand based on the type that was passed into it. ## HAIR `InlineAsm` is represented as an expression in the HAIR: ```rust crate enum ExprKind<'tcx> { // [..] InlineAsm { template: &'tcx [InlineAsmTemplatePiece], operands: Vec<InlineAsmOperand<'tcx>>, options: InlineAsmOptions, }, } crate enum InlineAsmOperand<'tcx> { In { reg: InlineAsmRegOrRegClass, expr: ExprRef<'tcx>, }, Out { reg: InlineAsmRegOrRegClass, late: bool, expr: Option<ExprRef<'tcx>>, }, InOut { reg: InlineAsmRegOrRegClass, late: bool, expr: ExprRef<'tcx>, }, SplitInOut { reg: InlineAsmRegOrRegClass, late: bool, in_expr: ExprRef<'tcx>, out_expr: Option<ExprRef<'tcx>>, }, Const { expr: ExprRef<'tcx>, }, SymFn { expr: ExprRef<'tcx>, }, SymStatic { expr: ExprRef<'tcx>, }, } ``` The only significant change compared to HIR is that `Sym` has been lowered to either a `SymFn` whose `expr` is a `Literal` ZST of the `fn`, or a `SymStatic` whose `expr` is a `StaticRef`. ## MIR `InlineAsm` is represented as a `Terminator` in the MIR: ```rust pub enum TerminatorKind<'tcx> { // [..] /// Block ends with an inline assembly block. This is a terminator since /// inline assembly is allowed to diverge. InlineAsm { /// The template for the inline assembly, with placeholders. template: &'tcx [InlineAsmTemplatePiece], /// The operands for the inline assembly, as `Operand`s or `Place`s. operands: Vec<InlineAsmOperand<'tcx>>, /// Miscellaneous options for the inline assembly. options: InlineAsmOptions, /// Destination block after the inline assembly returns, unless it is /// diverging (InlineAsmOptions::NORETURN). destination: Option<BasicBlock>, }, } pub enum InlineAsmOperand<'tcx> { In { reg: InlineAsmRegOrRegClass, value: Operand<'tcx>, }, Out { reg: InlineAsmRegOrRegClass, late: bool, place: Option<Place<'tcx>>, }, InOut { reg: InlineAsmRegOrRegClass, late: bool, in_value: Operand<'tcx>, out_place: Option<Place<'tcx>>, }, Const { value: Operand<'tcx>, }, SymFn { value: Box<Constant<'tcx>>, }, SymStatic { value: Box<Constant<'tcx>>, }, } ``` As part of HAIR lowering, `InOut` and `SplitInOut` operands are lowered to a split form with a separate `in_value` and `out_place`. Semantically, the `InlineAsm` terminator is similar to the `Call` terminator except that it has multiple output places where a `Call` only has a single return place output. The constant promotion pass is used to ensure that `const` operands are actually constants (using the same logic as `#[rustc_args_required_const]`). ## Codegen Operands are lowered one more time before being passed to LLVM codegen: ```rust pub enum InlineAsmOperandRef<'tcx, B: BackendTypes + ?Sized> { In { reg: InlineAsmRegOrRegClass, value: OperandRef<'tcx, B::Value>, }, Out { reg: InlineAsmRegOrRegClass, late: bool, place: Option<PlaceRef<'tcx, B::Value>>, }, InOut { reg: InlineAsmRegOrRegClass, late: bool, in_value: OperandRef<'tcx, B::Value>, out_place: Option<PlaceRef<'tcx, B::Value>>, }, Const { string: String, }, SymFn { instance: Instance<'tcx>, }, SymStatic { def_id: DefId, }, } ``` The operands are lowered to LLVM operands and constraint codes as follow: - `out` and the output part of `inout` operands are added first, as required by LLVM. Late output operands have a `=` prefix added to their constraint code, non-late output operands have a `=&` prefix added to their constraint code. - `in` operands are added normally. - `inout` operands are tied to the matching output operand. - `sym` operands are passed as function pointers or pointers, using the `"s"` constraint. - `const` operands are formatted to a string and directly inserted in the template string. The template string is converted to LLVM form: - `$` characters are escaped as `$$`. - `const` operands are converted to strings and inserted directly. - Placeholders are formatted as `${X:M}` where `X` is the operand index and `M` is the modifier character. Modifiers are converted from the Rust form to the LLVM form. The various options are converted to clobber constraints or LLVM attributes, refer to the [RFC](https://github.com/Amanieu/rfcs/blob/inline-asm/text/0000-inline-asm.md#mapping-to-llvm-ir) for more details. Note that LLVM is sometimes rather picky about what types it accepts for certain constraint codes so we sometimes need to insert conversions to/from a supported type. See the target-specific ISelLowering.cpp files in LLVM for details. # Adding support for new architectures Adding inline assembly support to an architecture is mostly a matter of defining the registers and register classes for that architecture. All the definitions for register classes are located in `src/librustc_target/asm/`. Additionally you will need to implement lowering of these register classes to LLVM constraint codes in `src/librustc_codegen_llvm/asm.rs`. | ||||
| 2020-05-18 | Rollup merge of #71973 - lcnr:lazy-norm, r=nikomatsakis | Dylan DPC | -1/+2 | |
| Lazy normalization of constants (Reprise) Continuation of #67890 by @skinny121. Initial implementation of #60471 for constants. Perform normalization/evaluation of constants lazily, which is known as lazy normalization. Lazy normalization is only enabled when using `#![feature(lazy_normalization_consts)]`, by default constants are still evaluated eagerly as there are currently. Lazy normalization of constants is achieved with a new ConstEquate predicate which type inferences uses to delay checking whether constants are equal to each other until later, avoiding cycle errors. Note this doesn't allow the use of generics within repeat count expressions as that is still evaluated during conversion to mir. There are also quite a few other known problems with lazy normalization which will be fixed in future PRs. r? @nikomatsakis fixes #71922, fixes #71986 | ||||
| 2020-05-18 | Check that asm const operands are actually constants | Amanieu d'Antras | -16/+65 | |
| 2020-05-18 | Add asm! to MIR | Amanieu d'Antras | -3/+25 | |
| 2020-05-18 | Auto merge of #72269 - RalfJung:unsafe-borrow-of-packed, r=Mark-Simulacrum | bors | -19/+19 | |
| move borrow-of-packed-field unsafety check out of loop Looks like during the place refactoring, this code somehow got into this loop even though it does not actually depend on the loop variables. | ||||
| 2020-05-17 | Auto merge of #72135 - oli-obk:const_prop_deaggregates, r=wesleywiser | bors | -1/+24 | |
| Propagate locals, even if they have unpropagatable assignments somewhere Second try for https://github.com/rust-lang/rust/pull/71946#discussion_r422967292 r? @wesleywiser cc @rust-lang/wg-mir-opt @RalfJung | ||||
