about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm
AgeCommit message (Collapse)AuthorLines
2024-07-25Auto merge of #127995 - workingjubilee:say-turings-prayer, r=BoxyUwUbors-33/+27
compiler: Never debug_assert in codegen In the name of Turing and his Hoarey heralds, assert our truths before creating a monster! The `rustc_codegen_llvm` and `rustc_codegen_ssa` crates are fairly critical for rustc's correctness. Small mistakes here can easily result in undefined behavior, since a "small mistake" can mean something like "link and execute the wrong code". We should probably run any and all asserts in these modules unconditionally on whether this is a "debug build", and damn the costs in performance. ...Especially because the costs in performance seem to be *nothing*. It is not clear how much correctness we gain here, but I'll take free correctness improvements.
2024-07-22Rollup merge of #127506 - liushuyu:s390x-target-features, r=davidtwcoTrevor Gross-1/+27
rustc_target: add known safe s390x target features This pull request adds known safe target features for s390x (aka IBM Z systems). Currently, these features are unstable since stabilizing the target features requires submitting proposals. The `vector` feature was added in IBM Z13 (`arch11`), and this is a SIMD feature for the newer IBM Z systems. The `backchain` attribute is the IBM Z way of adding frame pointers like unwinding capabilities (the "frame-pointer" switch on IBM Z and IBM POWER platforms will add _emulated_ frame pointers to the binary, which profilers can't use for unwinding the stack). Both attributes can be applied at the LLVM module or function levels. However, the `backchain` attribute has to be enabled for all the functions in the call stack to get a successful unwind process.
2024-07-20compiler: Never debug_assert in codegenJubilee Young-33/+27
The gains in performance are not worth the costs in correctness. This is partly because the gains are zero and the costs are unknown.
2024-07-19Rollup merge of #121533 - ratmice:wasm_init_fini_array, r=nnethercoteTrevor Gross-2/+8
Handle .init_array link_section specially on wasm Given that wasm-ld now has support for [.init_array](https://github.com/llvm/llvm-project/blob/8f2bd8ae68883592a333f4bdbed9798d66e68630/llvm/lib/MC/WasmObjectWriter.cpp#L1852), it appears we can easily implement that section by falling through to the normal path rather than taking the typical custom_section path for wasm. The wasm-ld appears to have a bunch of limitations. Only one static with the `link_section` in a crate or else you hit the fatal error in the link above "only one .init_array section fragment supported". They do not get merged. You can still call multiple constructors by setting it to an array. ``` unsafe extern "C" fn ctor() { println!("foo"); } #[used] #[link_section = ".init_array"] static FOO: [unsafe extern "C" fn(); 2] = [ctor, ctor]; ``` Another issue appears to be that if crate *A* depends on crate *B*, but *A* doesn't call any symbols from *B* and *B* doesn't `#[export_name = ...]` any symbols, then crate *B*'s constructor will not be called. The workaround to this is to provide an exported symbol in crate *B*.
2024-07-17rustc_codegen_llvm: properly passing backchain attribute to LLVM ...liushuyu-1/+27
... this is a special attribute that was made to be a target-feature in LLVM 18+, but in all previous versions, this "feature" is a naked attribute. We will have to handle this situation differently than all other target-features.
2024-07-16Rollup merge of #124033 - bjorn3:ar_archive_writer_0_3_0, r=davidtwcoTrevor Gross-42/+71
Sync ar_archive_writer to LLVM 18.1.3 From LLVM 15.0.0-rc3. This adds support for COFF archives containing Arm64EC object files and has various fixes for AIX big archive files.
2024-07-16Fix unsafe_op_in_unsafe_fn in compilerMichael Goulet-294/+368
2024-07-15coverage: Restrict `ExpressionUsed` simplification to `Code` mappingsZalathar-2/+9
In the future, branch and MC/DC mappings might have expressions that don't correspond to any single point in the control-flow graph. That makes it trickier to keep track of which expressions should expect an `ExpressionUsed` node. We therefore sidestep that complexity by only performing `ExpressionUsed` simplification for expressions associated directly with ordinary `Code` mappings.
2024-07-13Rollup merge of #127654 - nikic:llvm-ndebug-fix, r=cuviperJacob Pratt-1/+1
Fix incorrect NDEBUG handling in LLVM bindings We currently compile our LLVM bindings using `-DNDEBUG` if debuginfo for LLVM is disabled. However, `NDEBUG` doesn't have any relation to debuginfo, it controls whether assertions are enabled. Split the LLVM_NDEBUG environment variable into two, so that assertions and debuginfo are controlled independently. After this change, `LLVMRustDIBuilderInsertDeclareAtEnd` triggers an assertion failure on LLVM 19 due to an incorrect cast. Fix it by removing the unused return value entirely. r? `@cuviper`
2024-07-12Remove LLVMRustDIBuilderInsertDeclareAtEnd return valueNikita Popov-1/+1
The return value changed from an Instruction to a DbgRecord in LLVM 19. As we don't actually use the result, drop the return value entirely to support both.
2024-07-11Auto merge of #127614 - matthiaskrgr:rollup-8geziwi, r=matthiaskrgrbors-13/+1
Rollup of 8 pull requests Successful merges: - #124599 (Suggest borrowing on fn argument that is `impl AsRef`) - #127572 (Don't mark `DEBUG_EVENT` struct as `repr(packed)`) - #127588 (core: Limit remaining f16 doctests to x86_64 linux) - #127591 (Make sure that labels are defined after the primary span in diagnostics) - #127598 (Allows `#[diagnostic::do_not_recommend]` to supress trait impls in suggestions as well) - #127599 (Rename `lazy_cell_consume` to `lazy_cell_into_inner`) - #127601 (check is_ident before parse_ident) - #127605 (Remove extern "wasm" ABI) r? `@ghost` `@rustbot` modify labels: rollup
2024-07-11Auto merge of #127487 - tgross35:f16-f128-simd, r=Amanieubors-0/+2
Add `f16` and `f128` as simd types in LLVM `@sayantn` is working on adding SIMD for `f16` and hitting the `FloatingPointVector` error. This should fix it and unblock adding support for `simd_fma` and `simd_fabs` in stdarch.
2024-07-11Remove extern "wasm" ABINikita Popov-13/+1
Remove the unstable `extern "wasm"` ABI (`wasm_abi` feature tracked in #83788). As discussed in https://github.com/rust-lang/rust/pull/127513#issuecomment-2220410679 and following, this ABI is a failed experiment that did not end up being used for anything. Keeping support for this ABI in LLVM 19 would require us to switch wasm targets to the `experimental-mv` ABI, which we do not want to do. It should be noted that `Abi::Wasm` was internally used for two things: The `-Z wasm-c-abi=legacy` ABI that is still used by default on some wasm targets, and the `extern "wasm"` ABI. Despite both being `Abi::Wasm` internally, they were not the same. An explicit `extern "wasm"` additionally enabled the `+multivalue` feature. I've opted to remove `Abi::Wasm` in this patch entirely, instead of keeping it as an ABI with only internal usage. Both `-Z wasm-c-abi` variants are now treated as part of the normal C ABI, just with different different treatment in adjust_for_foreign_abi.
2024-07-09Auto merge of #127001 - beetrees:f16-debuginfo, r=michaelwoeristerbors-3/+40
Add Natvis visualiser and debuginfo tests for `f16` To render `f16`s in debuggers on MSVC targets, this PR changes the compiler to output `f16`s as `struct f16 { bits: u16 }`, and includes a Natvis visualiser that manually converts the `f16`'s bits to a `float` which is can then be displayed by debuggers. `gdb`, `lldb` and `cdb` tests are also included for `f16` . `f16`/`f128` MSVC debug info issue: #121837 Tracking issue: #116909
2024-07-09Add Natvis visualiser and debuginfo tests for `f16`beetrees-3/+40
2024-07-08Add `f16` and `f128` as SIMD types in LLVMTrevor Gross-0/+2
2024-07-07Sync ar_archive_writer to LLVM 18.1.3bjorn3-42/+71
From LLVM 15.0.0-rc3. This adds support for COFF archives containing Arm64EC object files and has various fixes for AIX big archive files.
2024-07-05Auto merge of #126171 - RalfJung:simd_bitmask_multibyte, r=workingjubileebors-8/+8
simd_bitmask intrinsic: add a non-power-of-2 multi-byte example r? `@calebzulawski` `@workingjubilee`
2024-07-04Auto merge of #123781 - RalfJung:miri-fn-identity, r=oli-obkbors-2/+2
Miri function identity hack: account for possible inlining Having a non-lifetime generic is not the only reason a function can be duplicated. Another possibility is that the function may be eligible for cross-crate inlining. So also take into account the inlining attribute in this Miri hack for function pointer identity. That said, `cross_crate_inlinable` will still sometimes return true even for `inline(never)` functions: - when they are `DefKind::Ctor(..) | DefKind::Closure` -- I assume those cannot be `InlineAttr::Never` anyway? - when `cross_crate_inline_threshold == InliningThreshold::Always` so maybe this is still not quite the right criterion to use for function pointer identity.
2024-07-03Rollup merge of #126803 - tgross35:verbose-asm, r=AmanieuMatthias Krüger-5/+5
Change `asm-comments` to `verbose-asm`, always emit user comments Implements what is described in https://github.com/rust-lang/compiler-team/issues/762 Tracking issue: https://github.com/rust-lang/rust/issues/126802
2024-07-03Auto merge of #125507 - compiler-errors:type-length-limit, r=lcnrbors-1/+2
Re-implement a type-size based limit r? lcnr This PR reintroduces the type length limit added in #37789, which was accidentally made practically useless by the caching changes to `Ty::walk` in #72412, which caused the `walk` function to no longer walk over identical elements. Hitting this length limit is not fatal unless we are in codegen -- so it shouldn't affect passes like the mir inliner which creates potentially very large types (which we observed, for example, when the new trait solver compiles `itertools` in `--release` mode). This also increases the type length limit from `1048576 == 2 ** 20` to `2 ** 24`, which covers all of the code that can be reached with craterbot-check. Individual crates can increase the length limit further if desired. Perf regression is mild and I think we should accept it -- reinstating this limit is important for the new trait solver and to make sure we don't accidentally hit more type-size related regressions in the future. Fixes #125460
2024-07-02Rename the `asm-comments` compiler flag to `verbose-asm`Trevor Gross-5/+5
Since this codegen flag now only controls LLVM-generated comments rather than all assembly comments, make the name more accurate (and also match Clang).
2024-07-02Fix spansMichael Goulet-2/+2
2024-07-02Give Instance::expect_resolve a spanMichael Goulet-0/+1
2024-07-02Miri function identity hack: account for possible inliningRalf Jung-2/+2
2024-07-02Rollup merge of #127168 - DianQK:cast-size, r=workingjubileeMatthias Krüger-1/+2
Use the aligned size for alloca at args/ret when the pass mode is cast Fixes #75839. Fixes #121028. The `load` and `store` instructions in LLVM access the aligned size. For example, `load { i64, i32 }` accesses 16 bytes on x86_64: https://alive2.llvm.org/ce/z/n8CHAp. BTW, this example is expected to be optimized to immediate UB by Alive2: https://rust.godbolt.org/z/b7xK7hv1c and https://alive2.llvm.org/ce/z/vZDtZH. r? compiler
2024-07-02Use the aligned size for alloca at args when the pass mode is cast.DianQK-1/+2
The `load` and `store` instructions in LLVM access the aligned size.
2024-07-01fix simd_bitmask return type for non-power-of-two inputs, and add testsRalf Jung-8/+8
2024-06-29Rollup merge of #123237 - bjorn3:debuginfo_refactor, r=compiler-errorsMatthias Krüger-58/+60
Various rustc_codegen_ssa cleanups
2024-06-25Support `#[patchable_function_entries]`Matthew Maurer-3/+6
See [RFC](https://github.com/maurer/rust-rfcs/blob/patchable-function-entry/text/0000-patchable-function-entry.md) (yet to be numbered) TODO before submission: * Needs an RFC * Improve error reporting for malformed attributes
2024-06-25Support for -Z patchable-function-entryMatthew Maurer-0/+26
`-Z patchable-function-entry` works like `-fpatchable-function-entry` on clang/gcc. The arguments are total nop count and function offset. See MCP rust-lang/compiler-team#704
2024-06-24Rollup merge of #124712 - Enselic:deprecate-inline-threshold, r=pnkfelixMichael Goulet-3/+0
Deprecate no-op codegen option `-Cinline-threshold=...` This deprecates `-Cinline-threshold` since using it has no effect. This has been the case since the new LLVM pass manager started being used, more than 2 years ago. Recommend using `-Cllvm-args=--inline-threshold=...` instead. Closes #89742 which is E-help-wanted.
2024-06-23compiler(nfc): -Cforce-frame-pointers is a FramePointerJubilee Young-2/+3
2024-06-22Rollup merge of #126555 - beetrees:f16-inline-asm-arm, r=AmanieuGuillaume Gomez-0/+39
Add `f16` inline ASM support for 32-bit ARM Adds `f16` inline ASM support for 32-bit ARM. SIMD vector types are taken from [here](https://developer.arm.com/architectures/instruction-sets/intrinsics/#f:`@navigationhierarchiesreturnbasetype=[float]&f:@navigationhierarchieselementbitsize=[16]&f:@navigationhierarchiesarchitectures=[A32]).` Relevant issue: #125398 Tracking issue: #116909 `@rustbot` label +F-f16_and_f128
2024-06-21Rollup merge of #126530 - beetrees:f16-inline-asm-riscv, r=AmanieuJubilee-6/+49
Add `f16` inline ASM support for RISC-V This PR adds `f16` inline ASM support for RISC-V. A `FIXME` is left for `f128` support as LLVM does not support the required `Q` (Quad-Precision Floating-Point) extension yet. Relevant issue: #125398 Tracking issue: #116909 `@rustbot` label +F-f16_and_f128
2024-06-21Remove type_i1 and type_struct from cg_ssabjorn3-14/+14
They are not representable by Cranelift
2024-06-21Remove check_overflow method from MiscMethodsbjorn3-8/+0
It can be retrieved from the Session too.
2024-06-21Remove const_bitcast from ConstMethodsbjorn3-4/+0
2024-06-21Remove PrintBackendInfo traitbjorn3-25/+29
It is only implemented for a single type. Directly passing this type is simpler and avoids overhead from indirect calls.
2024-06-21Move vcall_visibility_metadata optimization hint out of a debuginfo ↵bjorn3-7/+17
generation method
2024-06-21Add `f16` inline ASM support for RISC-Vbeetrees-6/+49
2024-06-21Add `f16` inline ASM support for 32-bit ARMbeetrees-0/+39
2024-06-18Remove redundant argument from `subdiagnostic` methodOli Scherer-1/+1
2024-06-18Use a dedicated type instead of a reference for the diagnostic contextOli Scherer-37/+41
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-16Rollup merge of #126365 - Dirbaio:collapse-debuginfo-statics, r=workingjubilee许杰友 Jieyou Xu (Joe)-2/+2
Honor collapse_debuginfo for statics. fixes #126363 <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r​? <reviewer name> -->
2024-06-15Rollup merge of #126424 - Enselic:sort-target-features, r=lqdMatthias Krüger-0/+5
Also sort `crt-static` in `--print target-features` output I didn't find `crt-static` at first (for `x86_64-unknown-linux-gnu`), because it was put at the bottom of the large and otherwise sorted list. Fully sort the list before we print it. Note that `llvm_target_features` starts out and remains sorted and does not need to be sorted an extra time. On my machine the diff is just: ```diff $ diff -u /tmp/before2.txt /tmp/after2.txt --- /tmp/before2.txt 2024-06-13 20:40:27.091636592 +0200 +++ /tmp/after2.txt 2024-06-13 20:39:54.584894891 +0200 ``@@`` -20,6 +20,7 ``@@`` bmi1 - Support BMI instructions. bmi2 - Support BMI2 instructions. cmpxchg16b - 64-bit with cmpxchg16b (this is true for most x86-64 chips, but not the first AMD chips). + crt-static - Enables C Run-time Libraries to be statically linked. ermsb - REP MOVS/STOS are fast. f16c - Support 16-bit floating point conversion instructions. fma - Enable three-operand fused multiple-add. ``@@`` -49,7 +50,6 ``@@`` xsavec - Support xsavec instructions. xsaveopt - Support xsaveopt instructions. xsaves - Support xsaves instructions. - crt-static - Enables C Run-time Libraries to be statically linked. Code-generation features supported by LLVM for this target: 16bit-mode - 16-bit mode (i8086). ``` I couldn't find a ui test that tested this output. Let's see if CI finds a regression tests.
2024-06-14Deprecate no-op codegen option `-Cinline-threshold=...`Martin Nordholts-3/+0
This deprecates `-Cinline-threshold` since using it has no effect. This has been the case since the new LLVM pass manager started being used, more than 2 years ago.
2024-06-14Also sort `crt-static` in `--print target-features` outputMartin Nordholts-0/+5
I didn't find `crt-static` at first (for `x86_64-unknown-linux-gnu`), because it was put at the bottom the large and otherwise sorted list. Fully sort the list before we print it. Note that `llvm_target_features` starts out sorted and does not need to be sorted an extra time.
2024-06-13Add `f16` and `f128` inline ASM support for `x86` and `x86-64`beetrees-0/+100
2024-06-13Honor collapse_debuginfo for statics.Dario Nieuwenhuis-2/+2
fixes #126363