about summary refs log tree commit diff
path: root/src/librustc_codegen_ssa
AgeCommit message (Collapse)AuthorLines
2020-03-26Introduce `EmitObj`.Nicholas Nethercote-32/+49
Currently, there are three fields in `ModuleConfig` that dictate how object files are emitted: `emit_obj`, `obj_is_bitcode`, and `embed_bitcode`. Some of the combinations of these fields are nonsensical, in particular having both `obj_is_bitcode` and `embed_bitcode` true at the same time. Also, currently: - we needlessly emit and then delete a bytecode file if `obj_is_bitcode` is true but `emit_obj` is false; - we needlessly embed bitcode in the LLVM module if `embed_bitcode` is true and `emit_obj` is false. This commit combines the three fields into one, with a new type `EmitObj` (and the auxiliary `BitcodeSection`) which can encode five different possibilities. In the old code, `set_flags` would set `obj_is_bitcode` and `embed_bitcode` on all three of the configs (`modules`, `allocator`, `metadata`) if the relevant other conditions were met, even if no object code needed to be emitted for one or more of them. Whereas `start_async_codegen` would set `emit_obj`, but only for those configs that need it. In the new code, `start_async_codegen` does all the work of setting `emit_obj`, and it only does that for the configs that need it. `set_flags` no longer sets anything related to object file emission.
2020-03-25make Size::from* methods generic in the integer type they acceptRalf Jung-1/+1
2020-03-25Remove `TargetOptions::embed_bitcode`.Nicholas Nethercote-9/+8
It's unused by any existing targets, and soon we'll be embedding full bitcode by default anyway.
2020-03-24Rollup merge of #70289 - nnethercote:refactor-codegen, r=eddybMazdak Farrokhzad-17/+22
Refactor `codegen` `codegen` in `src/librustc_codegen_llvm/back/write.rs` is long and has complex control flow. These commits refactor it and make it easier to understand.
2020-03-23Evaluate repeat expression lengths as late as possibleOliver Scherer-0/+3
2020-03-23Rollup merge of #70249 - lcnr:issue70125, r=eddybMazdak Farrokhzad-24/+19
handle ConstKind::Unresolved after monomorphizing fixes #70125 r? @bjorn3
2020-03-23Combine `ModuleConfig::embed_bitcode{,_marker}`.Nicholas Nethercote-14/+22
Because the `(true, true)` combination isn't valid.
2020-03-22Rollup merge of #70254 - matthiaskrgr:cl4ppy, r=CentrilDylan DPC-7/+3
couple more clippy fixes (let_and_return, if_same_then_else) * summarize if-else-code with identical blocks (clippy::if_same_then_else) * don't create variable bindings just to return the bound value immediately (clippy::let_and_return)
2020-03-22simplify eval_mir_constantBastian Kauschke-13/+3
2020-03-22handle unevaluated consts after monomophizeBastian Kauschke-21/+26
2020-03-22don't create variable bindings just to return the bound value immediately ↵Matthias Krüger-7/+3
(clippy::let_and_return)
2020-03-21Rollup merge of #70126 - wesleywiser:fix_miri_ice_neg_zst_enum_discr, ↵Dylan DPC-1/+6
r=RalfJung,eddyb Fix ICE caused by truncating a negative ZST enum discriminant Fixes #70114 r? @oli-obk or @RalfJung
2020-03-21Fix ICE caused by truncating a negative ZST enum discriminantWesley Wiser-1/+6
2020-03-21Rollup merge of #69965 - mark-i-m:codegen-utils, r=eddybMazdak Farrokhzad-24/+76
Refactorings to get rid of rustc_codegen_utils r? @eddyb cc #45276 After this, the only modules left in `rustc_codegen_utils` are - `link`: a bunch of linking-related functions (many dealing with file names). These are mostly consumed by save analysis, rustc_driver, rustc_interface, and of course codegen. I assume they live here because we don't want a dependency of save analysis on codegen... Perhaps they can be moved to librustc? - ~`symbol_names` and `symbol_names_test`: honestly it seems odd that `symbol_names_test` is not a submodule of `symbol_names`. It seems like these could honestly live in their own crate or move to librustc. Already name mangling is exported as the `symbol_name` query.~ (move it to its own crate) I don't mind doing either of the above as part of this PR or a followup if you want.
2020-03-20remove redundant returns (clippy::needless_return)Matthias Krüger-3/+3
2020-03-20Rollup merge of #69935 - davidtwco:issue-69925, r=eddybYuki Okushi-6/+11
codegen/mir: support polymorphic `InstanceDef`s cc #69925 This PR modifies the use of `subst_and_normalize_erasing_regions` on parts of the MIR bodies returned from `instance_mir`, so that `InstanceDef::CloneShim` and `InstanceDef::DropGlue` (where there is a type) do not perform substitutions. This avoids double substitutions and enables polymorphic `InstanceDef`s. r? @eddyb cc @nikomatsakis
2020-03-19Refactorings to begin getting rid of rustc_codegen_utilsMark Mansi-24/+76
2020-03-19Remove unused `ModuleConfig::emit_lto_bc` field.Nicholas Nethercote-3/+0
2020-03-18Rollup merge of #69920 - Centril:hir-cleanup, r=ZoxcMazdak Farrokhzad-22/+22
Remove some imports to the rustc crate - When we have `NestedVisitorMap::None`, we use `type Map = dyn intravisit::Map<'v>;` instead of the actual map. This doesn't actually result in dynamic dispatch (in the future we may want to use an associated type default to simplify the code). - Use `rustc_session::` imports instead of `rustc::{session, lint}`. r? @Zoxc
2020-03-17review feedback: add a comment describing the situationJoshua M. Clulow-0/+6
2020-03-17Auto merge of #69519 - 12101111:remove-proc-macro-check, r=nagisabors-5/+6
Don't use static crt by default when build proc-macro Don't check value of `crt-static` when build proc-macro crates, since they are always built dynamically. For more information, see https://github.com/rust-lang/cargo/issues/7563#issuecomment-591965320 I hope this will fix issues about compiling `proc_macro` crates on musl host without bring more issues. Fix https://github.com/rust-lang/cargo/issues/7563
2020-03-16use "gcc" instead of "cc" on *-sun-solaris systems when linkingJoshua M. Clulow-1/+7
On illumos and Solaris systems, Rust will use GCC as the link editor. Rust does this by invoking "cc", which on many (Linux and perhaps BSD) systems is generally either GCC or a GCC-compatible front-end. On historical Solaris systems, "cc" was often the Sun Studio compiler. This history casts a long shadow, and as such, even most modern illumos-based operating systems tend to install GCC as "gcc", without also making it available as "cc". We should invoke GCC as "gcc" on such systems to ensure we get the right compiler driver.
2020-03-16use direct imports for `rustc::{lint, session}`.Mazdak Farrokhzad-22/+22
2020-03-15More Method->Fn renamingMark Mansi-1/+1
2020-03-14Update `krate_attrs` and `get_module`John Kåre Alsaker-2/+2
2020-03-13Auto merge of #67502 - Mark-Simulacrum:opt-catch, r=Mark-Simulacrumbors-10/+18
Optimize catch_unwind to match C++ try/catch This refactors the implementation of catching unwinds to allow LLVM to inline the "try" closure directly into the happy path, avoiding indirection. This means that the catch_unwind implementation is (after this PR) zero-cost unless a panic is thrown. https://rust.godbolt.org/z/cZcUSB is an example of the current codegen in a simple case. Notably, the codegen is *exactly the same* if `-Cpanic=abort` is passed, which is clearly not great. This PR, on the other hand, generates the following assembly: ```asm # -Cpanic=unwind: push rbx mov ebx,0x2a call QWORD PTR [rip+0x1c53c] # <happy> mov eax,ebx pop rbx ret mov rdi,rax call QWORD PTR [rip+0x1c537] # cleanup function call call QWORD PTR [rip+0x1c539] # <unfortunate> mov ebx,0xd mov eax,ebx pop rbx ret # -Cpanic=abort: push rax call QWORD PTR [rip+0x20a1] # <happy> mov eax,0x2a pop rcx ret ``` Fixes #64224, and resolves #64222.
2020-03-14Rollup merge of #69954 - RalfJung:panic_if-assert, r=Centril,eddybYuki Okushi-13/+13
rename panic_if_ intrinsics to assert_ [Suggested by @eddyb](https://github.com/rust-lang/miri/issues/1222#issuecomment-598087523)
2020-03-13adjust enum namingRalf Jung-12/+12
2020-03-12rename panic_if_ intrinsics to assert_Ralf Jung-4/+4
2020-03-12Rollup merge of #69747 - spastorino:rename-rustc-guide, r=pietroalbiniMazdak Farrokhzad-2/+2
Rename rustc guide This is in preparation for https://github.com/rust-lang/rustc-guide/issues/470 Needs to be merged after we actually rename the guide. Have used this to rename: `git grep -l 'rustc_guide' | xargs sed -i 's/rustc_guide/rustc_dev_guide/g'` `git grep -l 'rustc-guide' | xargs sed -i 's/rustc-guide/rustc-dev-guide/g'` `git grep -l 'rustc guide' | xargs sed -i 's/rustc guide/rustc dev guide/g'`
2020-03-12codegen/mir: support polymorphic `InstanceDef`sDavid Wood-6/+11
This commit modifies the use of `subst_and_normalize_erasing_regions` on parts of the MIR bodies returned from `instance_mir`, so that `InstanceDef::CloneShim` and `InstanceDef::DropGlue` (where there is a type) do not perform substitutions. This avoids double substitutions and enables polymorphic `InstanceDef`s. Signed-off-by: David Wood <david@davidtw.co>
2020-03-11Rollup merge of #69850 - RalfJung:panic-bounds-check, r=eddybMazdak Farrokhzad-1/+5
panic_bounds_check: use caller_location, like PanicFnLangItem The `PanicFnLangItem` got switched to using `#[caller_location]` at some point, but `PanicBoundsCheckFnLangItem` was kept in the old style. For consistency, switch that one over to use `#[caller_location]` as well. This is also helpful for Miri as it means the `assert_panic` machine hook never needs to know the current `Span`.
2020-03-11Rollup merge of #66059 - RalfJung:panic-on-non-zero, r=eddybMazdak Farrokhzad-35/+92
mem::zeroed/uninit: panic on types that do not permit zero-initialization r? @eddyb @oli-obk Cc https://github.com/rust-lang/rust/issues/62825 Also see [this summary comment](https://github.com/rust-lang/rust/pull/66059#issuecomment-586734747)
2020-03-10rust-lang.github.io/rustc-dev-guide -> rustc-dev-guide.rust-lang.orgSantiago Pastorino-1/+1
2020-03-10Rename rustc-guide to rustc-dev-guideSantiago Pastorino-2/+2
2020-03-10Rollup merge of #69714 - spastorino:place-ref-lifetime, r=oli-obkMazdak Farrokhzad-5/+5
Make PlaceRef take just one lifetime r? @eddyb
2020-03-09Improve readabilityRalf Jung-2/+2
2020-03-09panic_bounds_check: use caller_location, like PanicFnLangItemRalf Jung-1/+5
2020-03-07Rollup merge of #69787 - spastorino:use-local-directly-its-copy, r=oli-obkMazdak Farrokhzad-1/+1
mir::Local is Copy we can pass it by value in these cases r? @oli-obk
2020-03-06mir::Local is Copy we can pass it by value in these casesSantiago Pastorino-1/+1
2020-03-06fix various typosMatthias Krüger-2/+2
2020-03-05Link to libgcc dynamically on windows-gnu when using dylib cratesAmanieu d'Antras-0/+14
2020-03-05Remove eh_unwind_resume lang itemAmanieu d'Antras-10/+4
2020-03-04PlaceRef<'a, 'tcx> -> PlaceRef<'tcx>Santiago Pastorino-5/+5
2020-03-04Don't use "if let" bindings to only check a value and not actually bind ↵Matthias Krüger-1/+1
anything. For example: `if let Some(_) = foo() {}` can be reduced to `if foo().is_some() {}` (clippy::redundant_pattern_matching)
2020-03-03Rollup merge of #69650 - matthiaskrgr:clnp, r=varkorDylan DPC-1/+1
cleanup more iterator usages (and other things) * Improve weird formatting by moving comment inside else-code block. * Use .any(x) instead of .find(x).is_some() on iterators. * Use .nth(x) instead of .skip(x).next() on iterators. * Simplify conditions like x + 1 <= y to x < y * Use let instead of match to get value of enum with single variant.
2020-03-03Make PlaceRef lifetimes of monomorphized_place_ty be both 'tcxSantiago Pastorino-1/+1
2020-03-03Make PlaceRef lifetimes of codegen_place be both 'tcxSantiago Pastorino-3/+3
2020-03-03Improve linking of crates with circular dependenciesTomasz Miąsko-7/+15
Previously, the code responsible for handling the cycles between crates introduces through weak lang items, would keep a set of missing language items: * extending it with items missing from the current crate, * removing items provided by the current crate, * grouping the crates when the set changed from non-empty back to empty. This could produce incorrect results, if a lang item was missing from a crate that comes after the crate that provides it (in the loop iteration order). In that case the grouping would not take place. The changes here address this specific failure scenario by keeping track of two separate sets of crates. Those that are required to link successfully, and those that are available for linking. Verified using test case from 69368.
2020-03-03Run format.12101111-1/+2