about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
AgeCommit message (Collapse)AuthorLines
2021-06-06Auto merge of #84171 - ricobbe:raw-dylib-via-llvm, r=petrochenkovbors-7/+78
Partial support for raw-dylib linkage First cut of functionality for issue #58713: add support for `#[link(kind = "raw-dylib")]` on `extern` blocks in lib crates compiled to .rlib files. Does not yet support `#[link_name]` attributes on functions, or the `#[link_ordinal]` attribute, or `#[link(kind = "raw-dylib")]` on `extern` blocks in bin crates; I intend to publish subsequent PRs to fill those gaps. It's also not yet clear whether this works for functions in `extern "stdcall"` blocks; I also intend to investigate that shortly and make any necessary changes as a follow-on PR. This implementation calls out to an LLVM function to construct the actual `.idata` sections as temporary `.lib` files on disk and then links those into the generated .rlib.
2021-06-06Auto merge of #79608 - alessandrod:bpf, r=nagisabors-0/+134
BPF target support This adds `bpfel-unknown-none` and `bpfeb-unknown-none`, two new no_std targets that generate little and big endian BPF. The approach taken is very similar to the cuda target, where `TargetOptions::obj_is_bitcode` is enabled and code generation is done by the linker. I added the targets to `dist-various-2`. There are [some tests](https://github.com/alessandrod/bpf-linker/tree/main/tests/assembly) in bpf-linker and I'm planning to add more. Those are currently not ran as part of rust CI.
2021-06-05Remove get_install_prefix_lib_path completelybjorn3-34/+4
It was broken anyway for rustup installs and nobody seems to have noticed.
2021-06-05Use sysroot instead of CFG_PREFIX for the rpathbjorn3-3/+2
CFG_PREFIX is incorrect for rustup installed rustc versions. It also causes unnecessary recompilation when changing the install prefix.
2021-06-05Auto merge of #85869 - tmiasko:box-free, r=nagisabors-29/+0
Remove special handling of `box_free` from `LocalAnalyzer` The special casing of `box_free` predates the use of dominators in analyzer. It is no longer necessary now that analyzer verifies that the first assignment dominates all uses.
2021-06-04Add first cut of functionality for #58713: support for #[link(kind = ↵Richard Cobbe-7/+78
"raw-dylib")]. This does not yet support #[link_name] attributes on functions, the #[link_ordinal] attribute, #[link(kind = "raw-dylib")] on extern blocks in bin crates, or stdcall functions on 32-bit x86.
2021-06-04Auto merge of #84449 - alexcrichton:metadata-in-object, r=nagisabors-56/+194
rustc: Store metadata-in-rlibs in object files This commit updates how rustc compiler metadata is stored in rlibs. Previously metadata was stored as a raw file that has the same format as `--emit metadata`. After this commit, however, the metadata is encoded into a small object file which has one section which is the contents of the metadata. The motivation for this commit is to fix a common case where #83730 arises. The problem is that when rustc crates a `dylib` crate type it needs to include entire rlib files into the dylib, so it passes `--whole-archive` (or the equivalent) to the linker. The problem with this, though, is that the linker will attempt to read all files in the archive. If the metadata file were left as-is (today) then the linker would generate an error saying it can't read the file. The previous solution was to alter the rlib just before linking, creating a new archive in a temporary directory which has the metadata file removed. This problem from before this commit is now removed if the metadata file is stored in an object file that the linker can read. The only caveat we have to take care of is to ensure that the linker never actually includes the contents of the object file into the final output. We apply similar tricks as the `.llvmbc` bytecode sections to do this. This involved changing the metadata loading code a bit, namely updating some of the LLVM C APIs used to use non-deprecated ones and fiddling with the lifetimes a bit to get everything to work out. Otherwise though this isn't intended to be a functional change really, only that metadata is stored differently in archives now. This should end up fixing #83730 because by default dylibs will no longer have their rlib dependencies "altered" meaning that split-debuginfo will continue to have valid paths pointing at the original rlibs. (note that we still "alter" rlibs if LTO is enabled to remove Rust object files and we also "alter" for the #[link(cfg)] feature, but that's rarely used). Closes #83730
2021-06-04rustc: Store metadata-in-rlibs in object filesAlex Crichton-56/+194
This commit updates how rustc compiler metadata is stored in rlibs. Previously metadata was stored as a raw file that has the same format as `--emit metadata`. After this commit, however, the metadata is encoded into a small object file which has one section which is the contents of the metadata. The motivation for this commit is to fix a common case where #83730 arises. The problem is that when rustc crates a `dylib` crate type it needs to include entire rlib files into the dylib, so it passes `--whole-archive` (or the equivalent) to the linker. The problem with this, though, is that the linker will attempt to read all files in the archive. If the metadata file were left as-is (today) then the linker would generate an error saying it can't read the file. The previous solution was to alter the rlib just before linking, creating a new archive in a temporary directory which has the metadata file removed. This problem from before this commit is now removed if the metadata file is stored in an object file that the linker can read. The only caveat we have to take care of is to ensure that the linker never actually includes the contents of the object file into the final output. We apply similar tricks as the `.llvmbc` bytecode sections to do this. This involved changing the metadata loading code a bit, namely updating some of the LLVM C APIs used to use non-deprecated ones and fiddling with the lifetimes a bit to get everything to work out. Otherwise though this isn't intended to be a functional change really, only that metadata is stored differently in archives now. This should end up fixing #83730 because by default dylibs will no longer have their rlib dependencies "altered" meaning that split-debuginfo will continue to have valid paths pointing at the original rlibs. (note that we still "alter" rlibs if LTO is enabled to remove Rust object files and we also "alter" for the #[link(cfg)] feature, but that's rarely used). Closes #83730
2021-06-04Move crate_name field from OngoingCodegen to CrateInfobjorn3-6/+4
2021-06-04Move windows_subsystem field from CodegenResults to CrateInfobjorn3-16/+17
2021-06-04Provide default MetadataLoaderbjorn3-1/+8
2021-06-04Remove unnecessary wasm_import_module_map providebjorn3-1/+0
For extern providers, both provide and provide_extern are called. wasm_import_module_map is already provided in provide, so it doesn't need to be provided in provide_extern.
2021-06-04Provide a default provide* implementation for CodegenBackendbjorn3-2/+2
Both cg_llvm and cg_clif don't override it. cg_spirv does override it, so it needs to be preserved.
2021-06-04Auto merge of #85385 - richkadel:simpler-simplify-with-coverage, r=wesleywiserbors-0/+9
Reland - Report coverage `0` of dead blocks Fixes: #84018 With `-Z instrument-coverage`, coverage reporting of dead blocks (for example, blocks dropped because a conditional branch is dropped, based on const evaluation) is now supported. Note, this PR relands an earlier, reverted PR that failed when compiling generators. The prior issues with generators has been resolved and a new test was added to prevent future regressions. Check out the resulting changes to test coverage of dead blocks in the test coverage reports in this PR. r? `@tmandry` fyi: `@wesleywiser`
2021-06-04Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514Yuki Okushi-4/+0
Remove unused feature gates The first commit removes a usage of a feature gate, but I don't expect it to be controversial as the feature gate was only used to workaround a limitation of rust in the past. (closures never being `Clone`) The second commit uses `#[allow_internal_unstable]` to avoid leaking the `trusted_step` feature gate usage from inside the index newtype macro. It didn't work for the `min_specialization` feature gate though. The third commit removes (almost) all feature gates from the compiler that weren't used anyway.
2021-06-03Remove check for projections in a branch without anyTomasz Miąsko-13/+0
The else branch is taken when projection slice is empty so everything except for the call to the `visit_local` is a dead code.
2021-06-03Remove unused support for `VarDebugInfo`Tomasz Miąsko-33/+4
This code has been dead since changes in 68961.
2021-06-02Respond to review feedbackWesley Wiser-0/+4
2021-06-02Change the type name from `_enum<..>` to `enum$<..>`Wesley Wiser-2/+2
This makes the type name inline with the proposed standard in #85269.
2021-06-02Generate better debuginfo for niche-layout enumsWesley Wiser-9/+50
Previously, we would generate a single struct with the layout of the dataful variant plus an extra field whose name contained the value of the niche (this would only really work for things like `Option<&_>` where we can determine that the `None` case maps to `0` but for enums that have multiple tag only variants, this doesn't work). Now, we generate a union of two structs, one which is the layout of the dataful variant and one which just has a way of reading the discriminant. We also generate an enum which maps the discriminant value to the tag only variants. We also encode information about the range of values which correspond to the dataful variant in the type name and then use natvis to determine which union field we should display to the user. As a result of this change, all niche-layout enums render correctly in WinDbg and Visual Studio!
2021-06-02Generate better debuginfo for directly tagged enumsWesley Wiser-0/+8
2021-06-01Tweak wasm_base target spec to indicate linker is not GNU and update linker ↵Luqman Aden-3/+7
inferring logic for wasm-ld.
2021-06-01Reland - Report coverage `0` of dead blocksRich Kadel-0/+9
Fixes: #84018 With `-Z instrument-coverage`, coverage reporting of dead blocks (for example, blocks dropped because a conditional branch is dropped, based on const evaluation) is now supported. Note, this PR relands an earlier, reverted PR that failed when compiling generators. The prior issues with generators has been resolved and a new test was added to prevent future regressions. Check out the resulting changes to test coverage of dead blocks in the test coverage reports in this PR.
2021-06-01Revert "Reduce the amount of untracked state in TyCtxt"Camille Gillot-2/+2
2021-05-31Remove unused feature gatesbjorn3-4/+0
2021-05-31Remove special handling of `box_free` from `LocalAnalyzer`Tomasz Miąsko-29/+0
The special casing of `box_free` predates the use of dominators in analyzer. It is no longer necessary now that analyzer verifies that the first assignment dominates all uses.
2021-05-30Make allocator_kind a query.Camille GILLOT-2/+2
2021-05-27Move metadata objects to before as-needed/zignore flags to make sure they ↵Luqman Aden-3/+6
are kept.
2021-05-24remove cfg(bootstrap)Pietro Albini-1/+0
2021-05-23Add support for BPF inline assemblyAlessandro Decina-0/+4
2021-05-23Pass target features to bpf-linkerAlessandro Decina-0/+4
2021-05-23Fix formattingAlessandro Decina-1/+4
2021-05-23Add BPF targetAlessandro Decina-0/+123
This change adds the bpfel-unknown-none and bpfeb-unknown-none targets which can be used to generate little endian and big endian BPF
2021-05-22native lib: defer the duplicate check after relevant_lib check.12101111-6/+8
2021-05-20Auto merge of #84665 - adamgemmell:aarch64-features, r=Amanieubors-2/+77
Update list of allowed aarch64 features I recently added these features to std_detect for aarch64 linux, pending [review](https://github.com/rust-lang/stdarch/pull/1146). I have commented any features not supported by LLVM 9, the current minimum version for Rust. Some (PAuth at least) were renamed between 9 & 12 and I've left them disabled. TME, however, is not in LLVM 9 but I've left it enabled. See https://github.com/rust-lang/stdarch/issues/993
2021-05-19Ensure all crypto components (AES, PMULL, SHA1/2) are available on arm/aarch64Adam Gemmell-0/+4
2021-05-19Rename fptoint to frinttsAdam Gemmell-1/+1
2021-05-19Remove LSE2Adam Gemmell-3/+1
2021-05-18Rollup merge of #85274 - luqmana:linker-is-gnu-gc-sections, r=petrochenkovJack Huey-9/+10
Only pass --[no-]gc-sections if linker is GNU ld. Fixes a regression from #84468 where linking now fails with solaris linkers. LinkerFlavor::Gcc does not always mean GNU ld specifically. And in the case of at least the solaris ld in illumos, that flag is unrecognized and will cause the linking step to fail. Even though removing the `is_like_solaris` branch from `gc_sections` in #84468 made sense as `-z ignore/record` are more analogous to the `--[no-]-as-needed` flags, it inadvertently caused solaris linkers to be passed the `--gc-sections` flag. So let's just change it to be more explicit about when we pass those flags.
2021-05-18Don't pass -pie to linker on windows targets.Luqman Aden-2/+5
2021-05-18Undo unnecessary changes.Luqman Aden-13/+4
2021-05-17Adjust linker_is_gnu branches for cases that don't work on windows.Luqman Aden-7/+16
2021-05-17Auto merge of #85178 - cjgillot:local-crate, r=oli-obkbors-31/+24
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-15/+25
2021-05-17rustc_codegen_ssa: only create backend `BasicBlock`s as-needed.Eduard-Mihai Burtescu-40/+41
2021-05-16Auto merge of #85290 - Amanieu:asm_const_int, r=nagisabors-2/+0
Remove support for floating-point constants in asm! Floating-point constants aren't very useful anyways and this simplifies the code since the type check can now be done in typeck. cc `@rust-lang/wg-inline-asm` r? `@nagisa`
2021-05-16Auto merge of #85316 - eddyb:cg-ssa-on-demand-cleanuppad, r=nagisabors-112/+109
rustc_codegen_ssa: generate MSVC cleanup pads on demand, like GNU landing pads. This unblocks #84993 in terms of codegen tests, as it brings the MSVC-style (`cleanup_pad`) EH (LLVM) block order in line with the GNU-style (`landing_pad`) EH (LLVM) block order, by having both of them be on-demand (instead of MSVC-style being eager and GNU-style lazy/on-demand). It also unifies the two implementations a bit, similar to #84699, but in the opposite direction (as that attempt made both kinds of EH pads eagerly built). ~~Opening as draft because I haven't done enough Windows testing just yet, of both this PR, and of #84993 rebased on it.~~ (**EDIT**: seems to be working as expected) r? `@nagisa`
2021-05-15Rollup merge of #85215 - richkadel:ice-fixes-minus-dead-blocks, r=tmandryGuillaume Gomez-3/+3
coverage bug fixes and some refactoring This replaces the relevant commits (2 and 3) from PR #85082, and also corrects an error querying for coverageinfo. 1. `coverageinfo` query needs to use the same MIR as codegen I ran into an error trying to fix dead block coverage and realized the `coverageinfo` query is getting a different MIR compared to the codegenned MIR, which can sometimes be a problem during mapgen. I changed that query to use the `InstandeDef` (which includes the generic parameter substitutions, prosibly specific to const params) instead of the `DefId` (without unknown/default const substitutions). 2. Simplified body_span and filtered span code Some code cleanup extracted from future (but unfinished) commit to fix coverage in attr macro functions. 3. Spanview needs the relevant body_span used for coverage The coverage body_span doesn't always match the function body_span. r? ```@tmandry```
2021-05-15rustc_codegen_ssa: generate MSVC cleanup pads on demand, like GNU landing pads.Eduard-Mihai Burtescu-112/+109
2021-05-14Remove support for floating-point constants in asm!Amanieu d'Antras-2/+0
Floating-point constants aren't very useful anyways and this simplifies the code since the type check can now be done in typeck.