about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa
AgeCommit message (Collapse)AuthorLines
2021-10-11Auto merge of #89597 - michaelwoerister:improve-vtable-debuginfo, r=wesleywiserbors-3/+64
Create more accurate debuginfo for vtables. Before this PR all vtables would have the same name (`"vtable"`) in debuginfo. Now they get an unambiguous name that identifies the implementing type and the trait that is being implemented. This is only one of several possible improvements: - This PR describes vtables as arrays of `*const u8` pointers. It would nice to describe them as structs where function pointer is represented by a field with a name indicative of the method it maps to. However, this requires coming up with a naming scheme that avoids clashes between methods with the same name (which is possible if the vtable contains multiple traits). - The PR does not update the debuginfo we generate for the vtable-pointer field in a fat `dyn` pointer. Right now there does not seem to be an easy way of getting ahold of a vtable-layout without also knowing the concrete self-type of a trait object. r? `@wesleywiser`
2021-10-09Rollup merge of #89634 - hawkw:eliza/enable-err-warn, r=oli-obkMatthias Krüger-5/+4
rustc_driver: Enable the `WARN` log level by default This commit changes the `tracing_subscriber` initialization in `rustc_driver` so that the `WARN` verbosity level is enabled by default when the `RUSTC_LOG` env variable is empty. If the `RUSTC_LOG` env variable is set, the filter string in the environment variable is honored, instead. Fixes #76824 Closes #89623 cc ``@eddyb,`` ``@oli-obk``
2021-10-08Auto merge of #89619 - michaelwoerister:incr-vtables, r=nagisabors-1/+1
Turn vtable_allocation() into a query This PR removes the untracked vtable-const-allocation cache from the `tcx` and turns the `vtable_allocation()` method into a query. The change is pretty straightforward and should be backportable without too much effort. Fixes https://github.com/rust-lang/rust/issues/89598.
2021-10-08Create more accurate debuginfo for vtables.Michael Woerister-3/+64
Before this commit all vtables would have the same name "vtable" in debuginfo. Now they get a name that identifies the implementing type and the trait that is being implemented.
2021-10-07Rollup merge of #88137 - joshtriplett:osx-strip-symbols-no-option, ↵Jubilee-12/+10
r=michaelwoerister On macOS, make strip="symbols" not pass any options to strip This makes the output with `strip="symbols"` match the result of just calling `strip` on the output binary, minimizing the size of the binary.
2021-10-07lol i forgot the syntax for my own crate's macrosEliza Weisman-2/+2
T_____T Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2021-10-07comma-related changesEliza Weisman-1/+1
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2021-10-07Turn tcx.vtable_allocation() into a query.Michael Woerister-1/+1
2021-10-07use structured fields in some existing warningsEliza Weisman-5/+4
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2021-10-06Enable AutoFDO.Michael Benfield-0/+7
This largely involves implementing the options debug-info-for-profiling and profile-sample-use and forwarding them on to LLVM. AutoFDO can be used on x86-64 Linux like this: rustc -O -Cdebug-info-for-profiling main.rs -o main perf record -b ./main create_llvm_prof --binary=main --out=code.prof rustc -O -Cprofile-sample-use=code.prof main.rs -o main2 Now `main2` will have feedback directed optimization applied to it. The create_llvm_prof tool can be obtained from this github repository: https://github.com/google/autofdo Fixes #64892.
2021-10-03Remove re-export.Camille GILLOT-1/+2
2021-10-03Move rustc_middle::middle::cstore to rustc_session.Camille GILLOT-5/+5
2021-10-01Rollup merge of #88820 - hlopko:add_pie_relocation_model, r=petrochenkovManish Goregaokar-2/+6
Add `pie` as another `relocation-model` value MCP: https://github.com/rust-lang/compiler-team/issues/461
2021-10-01Add `pie` as another `relocation-model` valueMarcel Hlopko-2/+6
2021-09-30Move EncodedMetadata to rustc_metadata.Camille GILLOT-5/+7
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-20Migrate to 2021Mark Rousskov-1/+1
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-22/+27
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-13/+21
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-17Rollup merge of #88751 - bjorn3:move_filesearch, r=oli-obkYuki Okushi-7/+4
Couple of changes to FileSearch and SearchPath * Turn a couple of regular comments into doc comments * Move `get_tools_search_paths` from `FileSearch` to `Session` * Use Lrc instead of Option to avoid duplication of a `SearchPath`
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-19/+19
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-8/+5
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-08Move get_tools_search_paths from FileSearch to Sessionbjorn3-7/+4
It only uses fields of FileSearch that are stored in Session too
2021-09-07Auto merge of #88161 - michaelwoerister:fix-whole-archive-no-bundle, ↵bors-10/+50
r=petrochenkov Fix handling of +whole-archive native link modifier. This PR fixes a bug in `add_upstream_native_libraries` that led to the `+whole-archive` modifier being ignored when linking in native libs. ~~Note that the PR does not address the situation when `+whole-archive` is combined with `+bundle`.~~ `@wesleywiser's` commit adds validation code that turns combining `+whole-archive` with `+bundle` into an error. Fixes https://github.com/rust-lang/rust/issues/88085. r? `@petrochenkov` cc `@wesleywiser` `@gcoakes`
2021-09-05Auto merge of #88499 - eddyb:layout-off, r=nagisabors-24/+16
Provide `layout_of` automatically (given tcx + param_env + error handling). After #88337, there's no longer any uses of `LayoutOf` within `rustc_target` itself, so I realized I could move the trait to `rustc_middle::ty::layout` and redesign it a bit. This is similar to #88338 (and supersedes it), but at no ergonomic loss, since there's no funky `C: LayoutOf<Ty = Ty>` -> `Ty: TyAbiInterface<C>` generic `impl` chain, and each `LayoutOf` still corresponds to one `impl` (of `LayoutOfHelpers`) for the specific context. After this PR, this is what's needed to get `trait LayoutOf` (with the `layout_of` method) implemented on some context type: * `TyCtxt`, via `HasTyCtxt` * `ParamEnv`, via `HasParamEnv` * a way to transform `LayoutError`s into the desired error type * an error type of `!` can be paired with having `cx.layout_of(...)` return `TyAndLayout` *without* `Result<...>` around it, such as used by codegen * this is done through a new `LayoutOfHelpers` trait (and so is specifying the type of `cx.layout_of(...)`) When going through this path (and not bypassing it with a manual `impl` of `LayoutOf`), the end result is that only the error case can be customized, the query itself and the success paths are guaranteed to be uniform. (**EDIT**: just noticed that because of the supertrait relationship, you cannot actually implement `LayoutOf` yourself, the blanket `impl` fully covers all possible context types that could ever implement it) Part of the motivation for this shape of API is that I've been working on querifying `FnAbi::of_*`, and what I want/need to introduce for that looks a lot like the setup in this PR - in particular, it's harder to express the `FnAbi` methods in `rustc_target`, since they're much more tied to `rustc` concepts. r? `@nagisa` cc `@oli-obk` `@bjorn3`
2021-09-05Auto merge of #88559 - bjorn3:archive_logic_dedup, r=cjgillotbors-19/+47
Move add_rlib and add_native_library to cg_ssa This deduplicates logic between codegen backends. cc `@antoyo` and `@khyperia` for cg_gcc and rust-gpu.
2021-09-04Auto merge of #88550 - dpaoliello:dpaoliello/allocdebuginfo, r=estebankbors-4/+11
Include debug info for the allocator shim Issue Details: In some cases it is necessary to generate an "allocator shim" to forward various Rust allocation functions (e.g., `__rust_alloc`) to an underlying function (e.g., `malloc`). However, since this allocator shim is a manually created LLVM module it is not processed via the normal module processing code and so no debug info is generated for it (if debugging info is enabled). Fix Details: * Modify the `debuginfo` code to allow creating debug info for a module without a `CodegenCx` (since it is difficult, and expensive, to create one just to emit some debug info). * After creating the allocator shim add in basic debug info.
2021-09-02rustc_target: move `LayoutOf` to `ty::layout`.Eduard-Mihai Burtescu-24/+16
2021-09-01Move add_rlib and add_native_library to cg_ssabjorn3-19/+47
This deduplicates logic between codegen backends
2021-08-31Include debug info for the allocator shimDaniel Paoliello-4/+11
Issue Details: In some cases it is necessary to generate an "allocator shim" to forward various Rust allocation functions (e.g., `__rust_alloc`) to an underlying function (e.g., `malloc`). However, since this allocator shim is a manually created LLVM module it is not processed via the normal module processing code and so no debug info is generated for it (if debugging info is enabled). Fix Details: * Modify the `debuginfo` code to allow creating debug info for a module without a `CodegenCx` (since it is difficult, and expensive, to create one just to emit some debug info). * After creating the allocator shim add in basic debug info.
2021-08-31Auto merge of #88506 - Mark-Simulacrum:fix-rlibs, r=ehussbors-1/+1
Fix loading large rlibs Bumps object crate to permit parsing archives with 64-bit table entries. These are primarily encountered when there's more than 4GB of archive data. cc https://github.com/gimli-rs/object/issues/365 Helps with https://github.com/rust-lang/rust/issues/88351, but will also need a beta backport r? `@ehuss` (mostly for the test)
2021-08-30Fix loading large rlibsMark Rousskov-1/+1
Bumps object crate to permit parsing archives with 64-bit table entries. These are primarily encountered when there's more than 4GB of archive data.
2021-08-30Don't allow both the `+bundle` and `+whole-archive` modifiers for rlibsWesley Wiser-0/+14