about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
AgeCommit message (Collapse)AuthorLines
2022-08-24Remove LLVM ARM bug workaroundMichael Benfield-11/+0
This memset was inserted as a workaround to Rust issue #34427, which was an LLVM bug that apparently no longer manifests.
2022-08-24Rollup merge of #99993 - petrochenkov:linkdated, r=bjorn3Matthias Krüger-18/+18
linker: Update some outdated comments r? ``@bjorn3``
2022-08-22Refactor part of codegen_call_terminatorEric Holk-47/+44
2022-08-19use <[u8]>::escape_ascii instead of core::ascii::escape_defaultKaDiWa-17/+8
2022-08-19Rollup merge of #100208 - RalfJung:dyn-upcast-nop, r=petrochenkovDylan DPC-0/+1
make NOP dyn casts not require anything about the vtable As suggested [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/144729-t-types/topic/dyn-upcasting.20stabilization/near/292151439). This matches what the codegen backends already do, and what Miri did do until https://github.com/rust-lang/rust/pull/99420 when I made it super extra paranoid.
2022-08-17Rollup merge of #100379 - davidtwco:triagebot-diag, r=Mark-SimulacrumMatthias Krüger-9/+11
triagebot: add translation-related mention groups - Move some code around so that triagebot can ping relevant parties when translation logic is modified. - Add mention groups to triagebot for translation-related files/folders. - Auto-label pull requests with changes to translation-related files/folders with `A-translation`. r? `@Mark-Simulacrum`
2022-08-16Move the cast_float_to_int fallback code to GCCJosh Stone-154/+3
Now that we require at least LLVM 13, that codegen backend is always using its intrinsic `fptosi.sat` and `fptoui.sat` conversions, so it doesn't need the manual implementation. However, the GCC backend still needs it, so we can move all of that code down there.
2022-08-15Rollup merge of #100528 - tux3:riscv-bitmanip-features, r=davidtwcoMatthias Krüger-0/+4
Support 1st group of RISC-V Bitmanip backend target features These target features use the same names as LLVM and `is_riscv_feature_detected!`, they are: - zba (address generation instructions) - zbb (basic bit manipulation) - zbc (carry-less multiplication) - zbs (single-bit manipulation) The extension is frozen and ratified, and I don't think we should expect LLVM to change those feature names in the future. For reference, the specification for the B extension can be found here: https://github.com/riscv/riscv-bitmanip/releases/download/1.0.0/bitmanip-1.0.0-38-g865e7a7.pdf) On my current project, I see a 7.6% reduction in binary size with these features on, so I have some incentive to try to silence the "unknown feature" warning from `-Ctarget-feature` =)
2022-08-15Auto merge of #98393 - michaelwoerister:new-cpp-like-enum-debuginfo, ↵bors-50/+6
r=wesleywiser debuginfo: Generalize C++-like encoding for enums. The updated encoding should be able to handle niche layouts where more than one variant has fields (as introduced in https://github.com/rust-lang/rust/pull/94075). The new encoding is more uniform as there is no structural difference between direct-tag, niche-tag, and no-tag layouts anymore. The only difference between those cases is that the "dataful" variant in a niche-tag enum will have a `(start, end)` pair denoting the tag range instead of a single value. The new encoding now also supports 128-bit tags, which occur in at least some standard library types. These tags are represented as `u64` pairs so that debuggers (which don't always have support for 128-bit integers) can reliably deal with them. The downside is that this adds quite a bit of complexity to the encoding and especially to the corresponding NatVis. The new encoding seems to increase the size of (x86_64-pc-windows-msvc) debuginfo by 10-15%. The size of binaries is not affected (release builds were built with `-Cdebuginfo=2`, numbers are in kilobytes): EXE | before | after | relative -- | -- | -- | -- cargo (debug) | 40453 | 40450 | +0% ripgrep (debug) | 10275 | 10273 | +0% cargo (release) | 16186 | 16185 | +0% ripgrep (release) | 4727 | 4726 | +0% PDB | before | after | relative -- | -- | -- | -- cargo (debug) | 236524 | 261412 | +11% ripgrep (debug) | 53140 | 59060 | +11% cargo (release) | 148516 | 169620 | +14% ripgrep (release) | 10676 | 11804 | +11% Given that the new encoding is more general, this is to be expected. Only platforms using C++-like debuginfo are affected -- which currently is only `*-pc-windows-msvc`. *TODO* - [x] Properly update documentation - [x] Add regression tests for new optimized enum layouts as introduced by #94075. r? `@wesleywiser`
2022-08-15errors: move translation logic into moduleDavid Wood-9/+11
Just moving code around so that triagebot can ping relevant parties when translation logic is modified. Signed-off-by: David Wood <david.wood@huawei.com>
2022-08-14feat: Target features for 1st group of RISC-V Bitmanip extensionstux3-0/+4
These use the same names as LLVM and is_riscv_feature_detected!: - zba (address generation instructions) - zbb (basic bit manipulation) - zbc (carry-less multiplication) - zbs (single-bit manipulation)
2022-08-12rustc_target: Update some old naming around self contained linkingVadim Petrochenkov-24/+26
The "fallback" naming pre-dates introduction of `-Clink-self-contained`
2022-08-12Use enum2<_> instead of enum<_> for Cpp-like debuginfo enum type names.Michael Woerister-2/+2
And add more comments about niche tag enum encoding.
2022-08-12debuginfo: Change C++-like encoding for enums.Michael Woerister-48/+4
The updated encoding should be able to handle niche layouts where more than one variant has fields.
2022-08-11Rollup merge of #99500 - tmandry:fuchsia-flags, r=petrochenkovMatthias Krüger-4/+16
Fix flags when using clang as linker for Fuchsia Don't add C runtime or set dynamic linker when linking with clang for Fuchsia. Clang already does this for us.
2022-08-10Fix flags when using clang as linker for FuchsiaTyler Mandry-4/+16
Don't add C runtime or set dynamic linker when linking with clang for Fuchsia. Clang already does this for us.
2022-08-09Add support for link-flavor rust-lld for macOSMary-1/+7
Also refactor iOS, watchOS and tvOS common code.
2022-08-06make NOP dyn casts not require anything about the vtableRalf Jung-0/+1
2022-08-06Change implementation of `-Z gcc-ld` and `lld-wrapper` againVadim Petrochenkov-14/+18
2022-08-05Auto merge of #100035 - workingjubilee:merge-functions, r=nikicbors-2/+5
Enable function merging when opt is for size It is, of course, natural to want to merge aliasing functions when optimizing for code size, since that can eliminate several bytes. And an exhaustive match helps make the code less brittle. Closes #98215.
2022-08-05Enable function merging when opt is for sizeJubilee Young-2/+5
It is, of course, natural to want to merge aliasing functions when optimizing for code size, since that can eliminate several bytes. And an exhaustive match helps make the code less brittle.
2022-08-04Auto merge of #100120 - matthiaskrgr:rollup-g6ycykq, r=matthiaskrgrbors-7/+10
Rollup of 6 pull requests Successful merges: - #98771 (Add support for link-flavor rust-lld for iOS, tvOS and watchOS) - #98835 (relate `closure_substs.parent_substs()` to parent fn in NLL) - #99746 (Use `TraitEngine` in more places that don't specifically need `FulfillmentContext::new_in_snapshot`) - #99786 (Recover from C++ style `enum struct`) - #99795 (Delay a bug when failed to normalize trait ref during specialization) - #100029 (Prevent ICE for `doc_alias` on match arm, statement, expression) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-08-03Add support for link-flavor rust-lld for iOS, tvOS and watchOSmary-7/+10
This adds support for rust-lld for Apple *OS targets. This was tested against targets "aarch64-apple-ios" and "aarch64-apple-ios-sim". For targets "armv7-apple-ios" and "armv7s-apple-ios", it doesn't link because of "symbols.o" not being generated with the correct CPU subtype (changes in the "object" crate needs to be done to support it).
2022-08-02Fix backwards-compatibility check for tests with `+whole-archive`Daniel Sommermann-1/+1
Fixes #100066
2022-08-01Auto merge of #99944 - bjorn3:hide_proc_macro_symbols, r=eddybbors-6/+6
Limit symbols exported from proc macros Only `__rustc_proc_macro_decls_*__` and `rust_metadata_*` need to be exported for proc macros to work. All other symbols only increase binary size and have the potential to conflict with symbols from the host compiler. Fixes https://github.com/rust-lang/rust/issues/99909 Fixes #59998 cc `@eddyb`
2022-07-31linker: Update some outdated commentsVadim Petrochenkov-18/+18
2022-07-31Rollup merge of #99844 - bjorn3:archive_builder_interface_refactor, r=nagisaDylan DPC-100/+123
Introduce an ArchiveBuilderBuilder This avoids monomorphizing all linker code for each codegen backend and will allow passing in extra information to the archive builder from the codegen backend. I'm going to use this in https://github.com/rust-lang/rust/pull/97485 to allow passing in the right function to extract symbols from object files to a generic archive builder to be used by cg_llvm, cg_clif and cg_gcc.
2022-07-31Add issue referencebjorn3-1/+1
2022-07-30Limit symbols exported from proc macrosbjorn3-6/+6
Only __rustc_proc_macro_decls_*__ and rust_metadata_* need to be exported for proc macros to work. All other symbols only increase binary size and have the potential to conflict with symbols from the host compiler.
2022-07-29Auto merge of #99467 - BelovDV:add_option_link_arg, r=petrochenkovbors-9/+29
flag '-l link-arg=___ was added #99427
2022-07-29Auto merge of #99512 - nikic:llvm-15-fixes, r=cuviperbors-81/+48
LLVM 15 compatibility fixes These are LLVM 15 compatibility fixes split out from #99464. There are three changes here: * Emit elementtype attribtue for ldrex/strex intrinsics. This is requires as part of the opaque pointers migration. * Make more tests compatible with opaque pointers. These are either new or aren't run on x86. * Remove a test for `#[rustc_allocator]`. Since #99574 there are more requirement on the function signature. I dropped the test entirely, since we already test the effect of the attribute elsewhere. * The main change: When a worker thread emits an error, wait for other threads to finish before unwinding the main thread and exiting. Otherwise workers may end up using globals for which destructors have already been run. This was probably never quite correct, but became an active problem with LLVM 15, because it started using global dtors in critical places, as part of ManagedStatic removal. Fixes #99432 (and probably also #95679). r? `@cuviper`
2022-07-28fix: remove fake no_dead_strip for osxcsmoe-3/+1
2022-07-28Introduce an ArchiveBuilderBuilderbjorn3-75/+124
This avoids monomorphizing all linker code for each codegen backend and will allow passing in extra information to the archive builder from the codegen backend.
2022-07-28Inline inject_dll_import_libbjorn3-24/+6
2022-07-28Move output argument from ArchiveBuilder::new to .build()bjorn3-19/+11
2022-07-27Also wait on other threads if a WorkerFatalError occursNikita Popov-5/+5
This means that codegen_aborted may be set when new codegen requests arrive, so drop some related assertions. The new work will simply be ignored.
2022-07-27Reliably signal coordinator thread on panic during ongoing codegenNikita Popov-76/+43
Replace the separate AbortCodegenOnDrop guard by integrating this functionality into OngoingCodegen (or rather, the Coordinator part of it). This ensures that we send a CodegenAborted message and wait for workers to finish even if the panic occurs outside codegen_crate() (e.g. inside join_codegen()). This requires some minor changes to the handling of CodegenAborted, as it can now occur when the main thread is LLVMing rather than Codegenning.
2022-07-26Lib kind -l link-arg:Daniil Belov-9/+29
arbitrary link argument like -C link-arg, but respecting relative order to other `-l` options, unstable
2022-07-26Auto merge of #98989 - dpaoliello:rawdylibbin, r=michaelwoeristerbors-8/+48
Enable raw-dylib for bin crates Fixes #93842 When `raw-dylib` is used in a `bin` crate, we need to collect all of the `raw-dylib` functions, generate the import library and add that to the linker command line. I also changed the tests so that 1) the C++ dlls are created after the Rust dlls, thus there is no chance of accidentally using them in the Rust linking process and 2) disabled generating import libraries when building with MSVC.
2022-07-26Rollup merge of #97077 - ouz-a:Optimize-backend, r=oli-obkYuki Okushi-9/+3
Simplify some code that depend on Deref Now that we can assume #97025 works, it's safe to expect Deref is always in the first place of projections. With this, I was able to simplify some code that depended on Deref's place in projections. When we are able to move Derefer before `ElaborateDrops` successfully we will be able to optimize more places. r? `@oli-obk`
2022-07-25Auto merge of #85673 - csmoe:export-exe-sym, r=bjorn3bors-5/+19
RFC-2841: add codegen flag export symbols from executable Closes #84161 r? `@nikomatsakis` `@Mark-Simulacrum`
2022-07-25Rollup merge of #99643 - daxpedda:sign-ext-wasm, r=oli-obkYuki Okushi-0/+1
Add `sign-ext` target feature to the WASM target Some target features are still missing from that list. See #97808 for basically the same PR by `@alexcrichton.` Related issue: #96472. PR introducing this issue: #87402.
2022-07-25feat: impl export-executable-symbolscsmoe-5/+19
2022-07-24Auto merge of #95548 - rcvalle:rust-cfi-2, r=nagisabors-15/+19
Add fine-grained LLVM CFI support to the Rust compiler This PR improves the LLVM Control Flow Integrity (CFI) support in the Rust compiler by providing forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their return and parameter types. 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 identifying C char and integer type uses at the time types are encoded (see Type metadata in the design document in the tracking issue https://github.com/rust-lang/rust/issues/89653). LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto). Thank you again, `@eddyb,` `@nagisa,` `@pcc,` and `@tmiasko` for all the help!
2022-07-23Add fine-grained LLVM CFI support to the Rust compilerRamon de C Valle-15/+19
This commit improves the LLVM Control Flow Integrity (CFI) support in the Rust compiler by providing forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their return and parameter types. 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 identifying C char and integer type uses at the time types are encoded (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).
2022-07-23Add `sign-ext` target feature to the WASM targetdAxpeDDa-0/+1
2022-07-22Enable raw-dylib for binariesDaniel Paoliello-8/+48
2022-07-22simplify more, ret_deref -> has_derefouz-a-2/+1
2022-07-22simplify some code that depend on Derefouz-a-8/+3
2022-07-22Rollup merge of #98868 - tmiasko:unreachable-coverage, r=wesleywiserDylan DPC-5/+2
Fix unreachable coverage generation for inlined functions To generate a function coverage we need at least one coverage counter, so a coverage from unreachable blocks is retained only when some live counters remain. The previous implementation incorrectly retained unreachable coverage, because it didn't account for the fact that those live counters can belong to another function due to inlining. Fixes #98833.