about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm
AgeCommit message (Collapse)AuthorLines
2024-08-08Rename struct_tail_erasing_lifetimes to struct_tail_for_codegenMichael Goulet-2/+2
2024-08-08Do normalize when computing struct tails in codegenMichael Goulet-2/+3
2024-08-08const vector passed to codegenJames Barford-Evans-5/+5
2024-08-07Rollup merge of #128679 - RalfJung:codegen-fn-attrs, r=nikicMatthias Krüger-11/+28
codegen: better centralize function declaration attribute computation For some reason, the codegen backend has two functions that compute which attributes a function declaration gets: `apply_attrs_llfn` and `attributes::from_fn_attrs`. They are called in different places, on entirely different layers of abstraction. To me the code seems cleaner if we centralize this entirely in `apply_attrs_llfn`, so that's what this PR does.
2024-08-07Rollup merge of #128221 - calebzulawski:implied-target-features, r=AmanieuMatthias Krüger-157/+170
Add implied target features to target_feature attribute See [zulip](https://rust-lang.zulipchat.com/#narrow/stream/208962-t-libs.2Fstdarch/topic/Why.20would.20target-feature.20include.20implied.20features.3F) for some context. Adds implied target features, e.g. `#[target_feature(enable = "avx2")]` acts like `#[target_feature(enable = "avx2,avx,sse4.2,sse4.1...")]`. Fixes #128125, fixes #128426 The implied feature sets are taken from [the rust reference](https://doc.rust-lang.org/reference/attributes/codegen.html?highlight=target-fea#x86-or-x86_64), there are certainly more features and targets to add. Please feel free to reassign this to whoever should review it. r? ``@Amanieu``
2024-08-07codegen: better centralize function attribute computationRalf Jung-11/+28
2024-08-07Rollup merge of #128206 - bjorn3:import_lib_writing_refactor, r=jieyouxuGuillaume Gomez-256/+26
Make create_dll_import_lib easier to implement This will make it easier to implement raw-dylib support in cg_clif and cg_gcc. This PR doesn't yet include an create_dll_import_lib implementation for cg_clif as I need to correctly implement dllimport in cg_clif first before raw-dylib can work at all with cg_clif. Required for https://github.com/rust-lang/rustc_codegen_cranelift/issues/1345
2024-08-07Disallow enabling features without their implied featuresCaleb Zulawski-2/+4
2024-08-07Hide implicit target features from diagnostics when possibleCaleb Zulawski-1/+1
2024-08-07Add implied features to non-target-feature functionsCaleb Zulawski-5/+21
2024-08-07Remove redundant implied featuresCaleb Zulawski-34/+2
2024-08-07Don't use LLVM to compute -Ctarget-featureCaleb Zulawski-110/+112
2024-08-07Don't use LLVM's target featuresCaleb Zulawski-18/+57
2024-08-07Refactor and fill out target feature listsCaleb Zulawski-13/+15
2024-08-07Add implied target features to target_feature attributeCaleb Zulawski-16/+0
2024-08-06Rollup merge of #128417 - tgross35:f16-f128-math, r=dtolnayTrevor Gross-8/+8
Add `f16` and `f128` math functions This adds intrinsics and math functions for `f16` and `f128` floating point types. Support is quite limited and some things are broken so tests don't run on many platforms, but this provides a starting point.
2024-08-05RISC-V also has sane nontemporal storesRalf Jung-1/+2
2024-08-05nontemporal_store: make sure that the intrinsic is truly just a hintRalf Jung-7/+23
2024-08-04Fix warning.Kyle Huey-1/+1
2024-08-04Use Span::is_dummy().Kyle Huey-1/+1
2024-08-04Implement a implicit target feature mechanismdaxpedda-0/+16
2024-08-03Special case DUMMY_SP to emit line 0/column 0 locations on DWARF platforms.Kyle Huey-2/+7
Line 0 has a special meaning in DWARF. From the version 5 spec: The compiler may emit the value 0 in cases where an instruction cannot be attributed to any source line. DUMMY_SP spans cannot be attributed to any line. However, because rustc internally stores line numbers starting at zero, lookup_debug_loc() adjusts every line number by one. Special casing DUMMY_SP to actually emit line 0 ensures rustc communicates to the debugger that there's no meaningful source code for this instruction, rather than telling the debugger to jump to line 1 randomly.
2024-08-01Specify the integer type of the `powi` LLVM intrinsicTrevor Gross-8/+8
Since LLVM <https://reviews.llvm.org/D99439> (4c7f820b2b20, "Update @llvm.powi to handle different int sizes for the exponent"), the size of the integer can be specified for the `powi` intrinsic. Make use of this so it is more obvious that integer size is consistent across all float types. This feature is available since LLVM 13 (October 2021). Based on bootstrap we currently support >= 17.0, so there should be no support problems.
2024-07-31Rollup merge of #127830 - tgross35:archive-failure-message, r=BoxyUwUMatthias Krüger-1/+3
When an archive fails to build, print the path Currently the output on failure is as follows: Compiling block-buffer v0.10.4 Compiling crypto-common v0.1.6 Compiling digest v0.10.7 Compiling sha2 v0.10.8 Compiling xz2 v0.1.7 error: failed to build archive: No such file or directory error: could not compile `bootstrap` (lib) due to 1 previous error Change this to print which file is being constructed, to give some hint about what is going on. error: failed to build archive at `path/to/output`: No such file or directory
2024-07-30Move mingw dlltool invocation to cg_ssabjorn3-159/+12
2024-07-30Move computation of decorated names out of the create_dll_import_lib methodbjorn3-18/+3
2024-07-30Move is_mingw_gnu_toolchain and i686_decorated_name to cg_ssabjorn3-70/+8
2024-07-30Move temp file name generation out of the create_dll_import_lib methodbjorn3-10/+4
2024-07-30Auto merge of #128378 - matthiaskrgr:rollup-i3qz9uo, r=matthiaskrgrbors-3/+28
Rollup of 4 pull requests Successful merges: - #127574 (elaborate unknowable goals) - #128141 (Set branch protection function attributes) - #128315 (Fix vita build of std and forbid unsafe in unsafe in the os/vita module) - #128339 ([rustdoc] Make the buttons remain when code example is clicked) r? `@ghost` `@rustbot` modify labels: rollup
2024-07-30Auto merge of #128250 - Amanieu:select_unpredictable, r=nikicbors-1/+41
Add `select_unpredictable` to force LLVM to use CMOV Since https://reviews.llvm.org/D118118, LLVM will no longer turn CMOVs into branches if it comes from a `select` marked with an `unpredictable` metadata attribute. This PR introduces `core::intrinsics::select_unpredictable` which emits such a `select` and uses it in the implementation of `binary_search_by`.
2024-07-30Rollup merge of #128141 - nikic:aarch64-bti, r=DianQK,cuviperMatthias Krüger-3/+28
Set branch protection function attributes Since LLVM 19, it is necessary to set not only module flags, but also function attributes for branch protection on aarch64. See https://github.com/llvm/llvm-project/commit/e15d67cfc2e5775cc79281aa860f3ad3be628f39 for the relevant LLVM change. Fixes https://github.com/rust-lang/rust/issues/127829.
2024-07-29Add `-Z embed-source=yes` to embed source code in DWARF debug infoMrmaxmeier-0/+11
2024-07-29Auto merge of #125016 - nicholasbishop:bishop-cb-112, r=tgross35bors-0/+2
Update compiler_builtins to 0.1.114 The `weak-intrinsics` feature was removed from compiler_builtins in https://github.com/rust-lang/compiler-builtins/pull/598, so dropped the `compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot. In https://github.com/rust-lang/compiler-builtins/pull/593, some builtins for f16/f128 were added. These don't work for all compiler backends, so add a `compiler-builtins-no-f16-f128` feature and disable it for cranelift and gcc.
2024-07-29Reformat `use` declarations.Nicholas Nethercote-471/+374
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-28Rollup merge of #127860 - klensy:dedup, r=Mark-SimulacrumGuillaume Gomez-1/+1
deps: dedup object, wasmparser, wasm-encoder * dedups one `object`, additional dupe will be removed, with next `thorin-dwp` update * `wasmparser` pinned to minor versions, so full merge isn't possible * same with `wasm-encoder` Turned off some features for `wasmparser` (see features https://github.com/bytecodealliance/wasm-tools/blob/v1.208.1/crates/wasmparser/Cargo.toml) in `run-make-support`, looks working?
2024-07-28Force LLVM to use CMOV for binary searchAmanieu d'Antras-1/+41
Since https://reviews.llvm.org/D118118, LLVM will no longer turn CMOVs into branches if it comes from a `select` marked with an `unpredictable` metadata attribute. This PR introduces `core::intrinsics::select_unpredictable` which emits such a `select` and uses it in the implementation of `binary_search_by`.
2024-07-28dedup objectklensy-1/+1
waiting on thorin-dwp update dedup one wasmparser run-make-support: drop some features for wasmparser dedupe wasm-encoder
2024-07-25LLVM: LLVM-20.0 removes MMX typesMatthew Maurer-2/+0
See llvm/llvm-project#98505
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-24Set branch protection function attributesNikita Popov-3/+28
Since LLVM 19, it is necessary to set not only module flags, but also function attributes for branch protection on aarch64. See https://github.com/llvm/llvm-project/commit/e15d67cfc2e5775cc79281aa860f3ad3be628f39 for the relevant LLVM change.
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-16When an archive fails to build, print the pathTrevor Gross-1/+3
Currently the output on failure is as follows: Compiling block-buffer v0.10.4 Compiling crypto-common v0.1.6 Compiling digest v0.10.7 Compiling sha2 v0.10.8 Compiling xz2 v0.1.7 error: failed to build archive: No such file or directory error: could not compile `bootstrap` (lib) due to 1 previous error Print which file is being constructed to give some hint about what is going on.
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.