about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/base.rs
AgeCommit message (Collapse)AuthorLines
2021-09-30Move EncodedMetadata to rustc_metadata.Camille GILLOT-1/+1
2021-09-05Auto merge of #88499 - eddyb:layout-off, r=nagisabors-2/+2
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-02rustc_target: move `LayoutOf` to `ty::layout`.Eduard-Mihai Burtescu-2/+2
2021-08-31Include debug info for the allocator shimDaniel Paoliello-3/+9
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-18Fold `vtable_trait_upcasting_coercion_new_vptr_slot` logic into obligation ↵Charles Lew-13/+2
processing.
2021-08-05Prepare call/invoke for opaque pointersJosh Stone-7/+8
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-2/+5
Implement inbounds_gep using LLVMBuildInBoundsGEP2 which takes an explicit type argument instead of deriving it from a pointer type.
2021-08-03Implement pointer casting.Charles Lew-41/+66
2021-07-07Auto merge of #86105 - bjorn3:link_info_refactor, r=petrochenkovbors-2/+18
Refactor the generation of the metadata for linking
2021-07-07Remove a sorting operation from used_cratesbjorn3-2/+18
2021-07-06Fold LinkerInfo into CrateInfobjorn3-3/+8
2021-07-06Remove unused panic_runtime field from CrateInfobjorn3-4/+0
2021-07-06Move LinkerInfo into CrateInfobjorn3-1/+4
2021-07-05Remove LibSourcebjorn3-4/+2
The information is stored in used_crate_source too anyway
2021-07-01Auto merge of #86749 - bjorn3:link_info_refactor_part1, r=petrochenkovbors-1/+1
Rename all_crate_nums query to crates and remove useless wrapper Split out of https://github.com/rust-lang/rust/pull/86105 r? `@petrochenkov`
2021-07-01Rename all_crate_nums query to crates and remove useless wrapperbjorn3-1/+1
2021-07-01Rollup merge of #86652 - nagisa:nagisa/non-leaf-fp, r=petrochenkovGuillaume Gomez-1/+1
Add support for leaf function frame pointer elimination This PR adds ability for the target specifications to specify frame pointer emission type that's not just “always” or “whatever cg decides”. In particular there's a new mode that allows omission of the frame pointer for leaf functions (those that don't call any other functions). We then set this new mode for Aarch64-based Apple targets. Fixes #86196
2021-06-30Add support for leaf fn frame pointer eliminationSimonas Kazlauskas-1/+1
This PR adds ability for the target specifications to specify frame pointer emission type that's not just “always” or “whatever cg decides”. In particular there's a new mode that allows omission of the frame pointer for leaf functions (those that don't call any other functions). We then set this new mode for Aarch64-based Apple targets. Fixes #86196
2021-06-20Make allocator_kind a query.Camille GILLOT-1/+1
2021-06-04Move crate_name field from OngoingCodegen to CrateInfobjorn3-0/+2
2021-06-04Move windows_subsystem field from CodegenResults to CrateInfobjorn3-0/+15
2021-06-01Revert "Reduce the amount of untracked state in TyCtxt"Camille Gillot-1/+1
2021-05-30Make allocator_kind a query.Camille GILLOT-1/+1
2021-05-17Auto merge of #85178 - cjgillot:local-crate, r=oli-obkbors-8/+7
Remove CrateNum parameter for queries that only work on local crate The pervasive `CrateNum` parameter is a remnant of the multi-crate rustc idea. Using `()` as query key in those cases avoids having to worry about the validity of the query key.
2021-05-17rustc_codegen_ssa: append blocks to functions w/o creating a builder.Eduard-Mihai Burtescu-1/+2
2021-05-12Use () for codegen queries.Camille GILLOT-1/+1
2021-05-12Use () for entry_fn.Camille GILLOT-5/+4
2021-05-12Use () in dependency_formats.Camille GILLOT-2/+2
2021-05-12Auto merge of #83610 - bjorn3:driver_cleanup, r=cjgillotbors-2/+4
rustc_driver cleanup Best reviewed one commit at a time.
2021-05-09Add primary marker on codegen unit to take charge of main_wrapper for ↵Charles Lew-14/+3
non-local cases.
2021-05-02Pass target_cpu to LinkerInfo::new instead of link_binarybjorn3-2/+4
This is one step towards separating the linking code from codegen backends
2021-04-29Implement RFC 1260 with feature_name `imported_main`.Charles Lew-5/+22
2021-04-03Remove attribute `#[link_args]`Vadim Petrochenkov-1/+0
2021-02-19Use a QueryContext for try_mark_green.Camille GILLOT-1/+1
2021-02-03rustc_codegen_ssa: tune codegen scheduling to reduce memory usageTyson Nottingham-7/+19
For better throughput during parallel processing by LLVM, we used to sort CGUs largest to smallest. This would lead to better thread utilization by, for example, preventing a large CGU from being processed last and having only one LLVM thread working while the rest remained idle. However, this strategy would lead to high memory usage, as it meant the LLVM-IR for all of the largest CGUs would be resident in memory at once. Instead, we can compromise by ordering CGUs such that the largest and smallest are first, second largest and smallest are next, etc. If there are large size variations, this can reduce memory usage significantly.
2021-02-01Rollup merge of #81536 - tgnottingham:time-passes-rss, r=oli-obkJonas Schievink-2/+12
Indicate both start and end of pass RSS in time-passes output Previously, only the end of pass RSS was indicated. This could easily lead one to believe that the change in RSS from one pass to the next was attributable to the second pass, when in fact it occurred between the end of the first pass and the start of the second. Also, improve alignment of columns. Sample of output: ``` time: 0.739; rss: 607MB -> 637MB item_types_checking time: 8.429; rss: 637MB -> 775MB item_bodies_checking time: 11.063; rss: 470MB -> 775MB type_check_crate time: 0.232; rss: 775MB -> 777MB match_checking time: 0.139; rss: 777MB -> 779MB liveness_and_intrinsic_checking time: 0.372; rss: 775MB -> 779MB misc_checking_2 time: 8.188; rss: 779MB -> 1019MB MIR_borrow_checking time: 0.062; rss: 1019MB -> 1021MB MIR_effect_checking ```
2021-01-31Auto merge of #81327 - RalfJung:codegen-no-const-fail, r=oli-obkbors-0/+5
codegen: assume constants cannot fail to evaluate https://github.com/rust-lang/rust/pull/80579 landed, so we can finally remove this old hack from codegen and instead assume that consts never fail to evaluate. :) r? `@oli-obk`
2021-01-30codegen: assume constants cannot fail to evaluateRalf Jung-0/+5
also don't submit code to LLVM when the session has errors
2021-01-29Indicate both start and end of pass RSS in time-passes outputTyson Nottingham-2/+12
Previously, only the end of pass RSS was indicated. This could easily lead one to believe that the change in RSS from one pass to the next was attributable to the second pass, when in fact it occurred between the end of the first pass and the start of the second. Also, improve alignment of columns.
2021-01-27Rollup merge of #81369 - tgnottingham:codegen-to-llvm-ir-wall-time, r=lcnrYuki Okushi-17/+14
rustc_codegen_ssa: use wall time for codegen_to_LLVM_IR time-passes entry Use elapsed wall time spent on codegen_to_LLVM_IR for all CGUs as a whole, rather than the sum for each CGU (the distinction matters for parallel builds, where some CGUs are processed in parallel).
2021-01-24rustc_codegen_ssa: use wall time for codegen_to_LLVM_IR time-passes entryTyson Nottingham-17/+14
Use elapsed wall time spent on codegen_to_LLVM_IR for all CGUs as a whole, rather than the sum for each CGU (the distinction matters for parallel builds, where some CGUs are processed in parallel).
2021-01-23Don't provide backend_optimization_level query for extern cratesbjorn3-1/+1
2021-01-13Remove is_dllimport_foreign_item def from cg_ssabjorn3-27/+0
It overwrites the definition from rustc_metadata
2020-12-31Rollup merge of #80323 - camelid:codegen-base-docs, r=nagisaDylan DPC-15/+0
Update and improve `rustc_codegen_{llvm,ssa}` docs Fixes #75342. These docs were very out of date and misleading. They even said that they codegen'd the *AST*! For some reason, the `rustc_codegen_ssa::base` docs were exactly identical to the `rustc_codegen_llvm::base` docs. They didn't really make sense, because they had LLVM-specific information even though `rustc_codegen_ssa` is supposed to be somewhat generic. So I removed them as they were misleading. r? ``@pnkfelix`` maybe?
2020-12-28Rollup merge of #79662 - bjorn3:move_more_code_out_of_codegen_backend, r=oli-obkDylan DPC-21/+0
Move some more code out of CodegenBackend::{codegen_crate,link} Kind of a follow up to #77795
2020-12-22Update and improve `rustc_codegen_{llvm,ssa}` docsCamelid-15/+0
These docs were very out of date and misleading. They even said that they codegen'd the *AST*! For some reason, the `rustc_codegen_ssa::base` docs were exactly identical to the `rustc_codegen_llvm::base` docs. They didn't really make sense, because they had LLVM-specific information even though `rustc_codegen_ssa` is supposed to be somewhat generic. So I removed them as they were misleading.
2020-12-23Exclude unnecessary info from CodegenResultsVictor Ding-2/+3
`foreign_module` and `wasm_import_module` are not needed for linking, and hence can be removed from CodegenResults.
2020-12-17Move some code out of CodegenBackend::{codegen_crate,link}bjorn3-21/+0
2020-11-16compiler: fold by valueBastian Kauschke-1/+1
2020-11-08Collapse all uses of `target.options.foo` into `target.foo`Vadim Petrochenkov-3/+3
with an eye on merging `TargetOptions` into `Target`. `TargetOptions` as a separate structure is mostly an implementation detail of `Target` construction, all its fields logically belong to `Target` and available from `Target` through `Deref` impls.