about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/mir
AgeCommit message (Collapse)AuthorLines
2021-12-30keep noinline for system llvm < 14Erik Desjardins-2/+1
2021-12-29Mark drop calls in landing pads cold instead of noinlineErik Desjardins-5/+2
Now that deferred inlining has been disabled in LLVM, this shouldn't cause catastrophic size blowup.
2021-12-22Store a `DefId` instead of an `AdtDef` in `AggregateKind::Adt`Aaron Hill-2/+2
The `AggregateKind` enum ends up in the final mir `Body`. Currently, any changes to `AdtDef` (regardless of how significant they are) will legitimately cause the overall result of `optimized_mir` to change, invalidating any codegen re-use involving that mir. This will get worse once we start hashing the `Span` inside `FieldDef` (which is itself contained in `AdtDef`). To try to reduce these kinds of invalidations, this commit changes `AggregateKind::Adt` to store just the `DefId`, instead of the full `AdtDef`. This allows the result of `optimized_mir` to be unchanged if the `AdtDef` changes in a way that doesn't actually affect any of the MIR we build.
2021-12-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-2/+2
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-2/+2
2021-12-15Remove `in_band_lifetimes` from `rustc_codegen_ssa`LegionMammal978-2/+2
See #91867 for more information.
2021-12-03LLVM codgen support for unwinding inline assemblycynecx-10/+56
2021-12-03Add initial AST and MIR support for unwinding from inline assemblyAmanieu d'Antras-0/+2
2021-11-27Use iterator instead of recursion in `codegen_place`SparrowLii-76/+67
2021-11-14Remove workaround for the forward progress handling in LLVMAndreas Jonson-11/+0
2021-11-06pointee_info_at() does not need mutable accessMatthias Krüger-1/+1
2021-11-04clippy::perf fixesMatthias Krüger-2/+2
2021-10-27Auto merge of #89652 - rcvalle:rust-cfi, r=nagisabors-3/+43
Add LLVM CFI support to the Rust compiler This PR adds LLVM Control Flow Integrity (CFI) support to the Rust compiler. It initially provides forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their number of arguments. Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by defining and using compatible type identifiers (see Type metadata in the design document in the tracking issue #89653). LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto). Thank you, `@eddyb` and `@pcc,` for all the help!
2021-10-26Properly check `target_features` not to trigger an assertionYuki Okushi-1/+3
2021-10-25Add LLVM CFI support to the Rust compilerRamon de C Valle-3/+43
This commit adds LLVM Control Flow Integrity (CFI) support to the Rust compiler. It initially provides forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their number of arguments. Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by defining and using compatible type identifiers (see Type metadata in the design document in the tracking issue #89653). LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto).
2021-10-20Remove NullOp::BoxGary Guo-27/+0
2021-10-16Adopt let_else across the compilerest31-3/+1
This performs a substitution of code following the pattern: let <id> = if let <pat> = ... { identity } else { ... : ! }; To simplify it to: let <pat> = ... { identity } else { ... : ! }; By adopting the let_else feature.
2021-09-25Auto merge of #89030 - nbdd0121:box2, r=jonas-schievinkbors-0/+13
Introduce `Rvalue::ShallowInitBox` Polished version of #88700. Implements MCP rust-lang/compiler-team#460, and should allow #43596 to go forward. In short, creating an empty box is split from a nullary-op `NullOp::Box` into two steps, first a call to `exchange_malloc`, then a `Rvalue::ShallowInitBox` which transmutes `*mut u8` to a shallow-initialized `Box<T>`. This allows the `exchange_malloc` call to unwind. Details can be found in the MCP. `NullOp::Box` is not yet removed, purely to make reverting easier in case anything goes wrong as the result of this PR. If revert is needed a reversion of "Use Rvalue::ShallowInitBox for box expression" commit followed by a test bless should be sufficient. Experiments in #88700 showed a very slight compile-time perf regression due to (supposedly) slightly more time spent in LLVM. We could omit unwind edge generation (in non-`oom=panic` case) in box expression MIR construction to restore perf; but I don't think it's necessary since runtime perf isn't affected and perf difference is rather small.
2021-09-25Introduce `Rvalue::ShallowInitBox`Gary Guo-0/+13
2021-09-24Auto merge of #89120 - In-line:remove_unneded_visible_parents_map, r=estebankbors-10/+15
Disable visible path calculation for PrettyPrinter in Ok path of compiler
2021-09-22Support `#[track_caller]` on closures and generatorsAaron Hill-7/+30
This PR allows applying a `#[track_caller]` attribute to a closure/generator expression. The attribute as interpreted as applying to the compiler-generated implementation of the corresponding trait method (`FnOnce::call_once`, `FnMut::call_mut`, `Fn::call`, or `Generator::resume`). This feature does not have its own feature gate - however, it requires `#![feature(stmt_expr_attributes)]` in order to actually apply an attribute to a closure or generator. This is implemented in the same way as for functions - an extra location argument is appended to the end of the ABI. For closures, this argument is *not* part of the 'tupled' argument storing the parameters - the final closure argument for `#[track_caller]` closures is no longer a tuple. For direct (monomorphized) calls, the necessary support was already implemented - we just needeed to adjust some assertions around checking the ABI and argument count to take closures into account. For calls through a trait object, more work was needed. When creating a `ReifyShim`, we need to create a shim for the trait method (e.g. `FnOnce::call_mut`) - unlike normal functions, closures are never invoked directly, and always go through a trait method. Additional handling was needed for `InstanceDef::ClosureOnceShim`. In order to pass location information throgh a direct (monomorphized) call to `FnOnce::call_once` on an `FnMut` closure, we need to make `ClosureOnceShim` aware of `#[tracked_caller]`. A new field `track_caller` is added to `ClosureOnceShim` - this is used by `InstanceDef::requires_caller` location, allowing codegen to pass through the extra location argument. Since `ClosureOnceShim.track_caller` is only used by codegen, we end up generating two identical MIR shims - one for `track_caller == true`, and one for `track_caller == false`. However, these two shims are used by the entire crate (i.e. it's two shims total, not two shims per unique closure), so this shouldn't a big deal.
2021-09-22Auto merge of #88629 - wesleywiser:fix_debuginfo_for_scalarpair_params, ↵bors-15/+11
r=oli-obk Fix debuginfo for parameters passed via the ScalarPair abi on Windows Mark all of these as locals so the debugger does not try to interpret them as being a pointer to the value. This extends the approach used in #81898. Fixes #88625
2021-09-21Disable visible path calculation for PrettyPrinter in Ok path of compilerAlik Aslanyan-10/+15
2021-09-19Auto merge of #88575 - eddyb:fn-abi-queries, r=nagisabors-18/+15
Querify `FnAbi::of_{fn_ptr,instance}` as `fn_abi_of_{fn_ptr,instance}`. *Note: opening this PR as draft because it's based on #88499* This more or less replicates the `LayoutOf::layout_of` setup from #88499, to replace `FnAbi::of_{fn_ptr,instance}` with `FnAbiOf::fn_abi_of_{fn_ptr,instance}`, and also route them through queries (which `layout_of` has used for a while). The two changes at the use sites (other than the names) are: * return type is now wrapped in `&'tcx` * the value *is* interned, which may affect performance * the `extra_args` list is now an interned `&'tcx ty::List<Ty<'tcx>>` * should be cheap (it's empty for anything other than C variadics) Theoretically, a `FnAbiOfHelpers` implementer could choose to keep the `Result<...>` instead of eagerly erroring, but the only existing users of these APIs are codegen backends, so they don't (want to) take advantage of this. At least miri could make use of this, since it prefers propagating errors (it "just" doesn't use `FnAbi` yet - cc `@RalfJung).` The way this is done is probably less efficient than what is possible, because the queries handle the correctness-oriented API (i.e. the split into `fn` pointers vs instances), whereas a lower-level query could end up with more reuse between different instances with identical signatures. r? `@nagisa` cc `@oli-obk` `@bjorn3`
2021-09-19Rollup merge of #88855 - calebzulawski:feature/simd_shuffle, r=nagisaYuki Okushi-2/+6
Allow simd_shuffle to accept vectors of any length cc ``@rust-lang/project-portable-simd`` ``@workingjubilee``
2021-09-18Querify `fn_abi_of_{fn_ptr,instance}`.Eduard-Mihai Burtescu-14/+11
2021-09-18ty::layout: replicate `layout_of` setup for `fn_abi_of_{fn_ptr,instance}`.Eduard-Mihai Burtescu-9/+9
2021-09-18Remove support for reentrant start blocks from codegenTomasz Miąsko-19/+5
The start block is guaranteed not to have any basic block predecessors.
2021-09-18ty::layout: intern `FnAbi`s as `&'tcx`.Eduard-Mihai Burtescu-2/+2
2021-09-16Fix shuffle index constant not being monomorphized.Caleb Zulawski-2/+6
2021-09-13Update compiler/rustc_codegen_ssa/src/mir/mod.rsOli Scherer-1/+1
2021-09-13Fix debuginfo for ScalarPair abi parametersWesley Wiser-15/+10
Mark all of these as locals so the debugger does not try to interpret them as being a pointer to the value. This extends the approach used in PR #81898.
2021-09-13Add tracing level for codegen_mirWesley Wiser-0/+1
2021-09-12Auto merge of #88839 - nbdd0121:alignof, r=nagisabors-15/+21
Introduce NullOp::AlignOf This PR introduces `Rvalue::NullaryOp(NullOp::AlignOf, ty)`, which will be lowered from `align_of`, similar to `size_of` lowering to `Rvalue::NullaryOp(NullOp::SizeOf, ty)`. The changes are originally part of #88700 but since it's not dependent on other changes and could have performance impact on its own, it's separated into its own PR.
2021-09-13Introduce NullOp::AlignOfGary Guo-15/+21
2021-09-09rename `is_valid_for` to `is_valid`Andreas Liljeqvist-1/+1
2021-09-09Make `abi::Abi` `Copy` and remove a *lot* of refsAndreas Liljeqvist-14/+14
fix fix Remove more refs and clones fix more fix
2021-09-09derive Copy for WrappingRange and ScalarAndreas Liljeqvist-1/+1
2021-09-09Add methods for checking for full ranges to `Scalar` and `WrappingRange`Andreas Liljeqvist-4/+3
Move *_max methods back to util change to inline instead of inline(always) Remove valid_range_exclusive from scalar Use WrappingRange instead implement always_valid_for in a safer way Fix accidental edit
2021-09-02rustc_target: move `LayoutOf` to `ty::layout`.Eduard-Mihai Burtescu-10/+9
2021-08-30rustc_target: `TyAndLayout::field` should never error.Eduard-Mihai Burtescu-4/+2
2021-08-26update `TypeFlags` to deal with missing ct substslcnr-2/+2
2021-08-25Auto merge of #88242 - bonega:allocation_range, r=oli-obkbors-4/+4
Use custom wrap-around type instead of RangeInclusive Two reasons: 1. More memory is allocated than necessary for `valid_range` in `Scalar`. The range is not used as an iterator and `exhausted` is never used. 2. `contains`, `count` etc. methods in `RangeInclusive` are doing very unhelpful(and dangerous!) things when used as a wrap-around range. - In general this PR wants to limit potentially confusing methods, that have a low probability of working. Doing a local perf run, every metric shows improvement except for instructions. Max-rss seem to have a very consistent improvement. Sorry - newbie here, probably doing something wrong.
2021-08-22Use custom wrap-around type instead of RangeAndreas Liljeqvist-4/+4
2021-08-22Fix typos “a”→“an”Frank Steffahn-1/+1
2021-08-05Prepare call/invoke for opaque pointersJosh Stone-4/+12
Rather than relying on `getPointerElementType()` from LLVM function pointers, we now pass the function type explicitly when building `call` or `invoke` instructions.
2021-08-04Prepare inbounds_gep for opaque pointersTomasz Miąsko-3/+16
Implement inbounds_gep using LLVMBuildInBoundsGEP2 which takes an explicit type argument instead of deriving it from a pointer type.
2021-08-04Prepare gep for opaque pointersTomasz Miąsko-3/+5
Implement gep using LLVMBuildGEP2 which takes an explicit type argument instead of deriving it from a pointer type.
2021-08-04Prepare struct_gep for opaque pointersTomasz Miąsko-4/+9
Imlement struct_gep using LLVMBuildStructGEP2 which takes an explicit type argument instead of deriving it from a pointer type.
2021-08-03Implement pointer casting.Charles Lew-19/+8