about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
AgeCommit message (Collapse)AuthorLines
2024-10-28compiler: Add `is_uninhabited` and use LayoutS accessorsJubilee Young-3/+3
This reduces the need of the compiler to peek on the fields of LayoutS.
2024-10-28Add a new `wide-arithmetic` feature for WebAssemblyAlex Crichton-0/+3
This commit adds a new rustc target feature named `wide-arithmetic` for WebAssembly targets. This corresponds to the [wide-arithmetic] proposal for WebAssembly which adds new instructions catered towards accelerating integer arithmetic larger than 64-bits. This proposal to WebAssembly is not standard yet so this new feature is flagged as an unstable target feature. Additionally Rust's LLVM version doesn't support this new feature yet since support will first be added in LLVM 20, so the feature filtering logic for LLVM is updated to handle this. I'll also note that I'm not currently planning to add wasm-specific intrinsics to `std::arch::wasm32` at this time. The currently proposed instructions are all accessible through `i128` or `u128`-based operations which Rust already supports, so intrinsic shouldn't be necessary to get access to these new instructions. [wide-arithmetic]: https://github.com/WebAssembly/wide-arithmetic
2024-10-28fix clippy::clone_on_ref_ptr for compilerklensy-1/+1
2024-10-28refactor: cleaner check to return NoneChrisCho-H-4/+1
2024-10-28Use a type-safe helper to cast `&str` and `&[u8]` to `*const c_char`Zalathar-87/+110
2024-10-27Auto merge of #132167 - Zalathar:llvm-wrappers, r=jieyouxubors-111/+133
Replace some LLVMRust wrappers with calls to the LLVM C API This PR removes the LLVMRust wrapper functions for getting/setting linkage and visibility, and replaces them with direct calls to the corresponding functions in LLVM's C API. To make this convenient and sound, two pieces of supporting code have also been added: - A simple proc-macro that derives `TryFrom<u32>` for fieldless enums - A wrapper type for C enum values returned by LLVM functions, to ensure soundness if LLVM returns an enum value we don't know about In a few places, the use of safe wrapper functions means that an `unsafe` block is no longer needed, so the affected code has changed its indentation level.
2024-10-27Auto merge of #131900 - mrkajetanp:target-feature-pauth-lr, r=Amanieubors-0/+1
rustc_target: Add pauth-lr aarch64 target feature Add the pauth-lr target feature, corresponding to aarch64 FEAT_PAuth_LR. This feature has been added in LLVM 19. It is currently not supported by the Linux hwcap and so we cannot add runtime feature detection for it at this time. r? `@Amanieu`
2024-10-27Use LLVM-C APIs for getting/setting visibilityZalathar-6/+6
2024-10-26Rollup merge of #132124 - Zalathar:consolidate-covstar, r=jieyouxu许杰友 Jieyou Xu (Joe)-144/+102
coverage: Consolidate creation of covmap/covfun records This code for creating covmap/covfun records during codegen was split across multiple functions and files for dubious historical reasons. Having it all in one place makes it easier to follow. This PR also includes two semi-related cleanups: - Getting the codegen context's `coverage_cx` state is made infallible, since it should always exist when running the code paths that need it. - The value of `covfun_section_name` is saved in the codegen context, since it never changes at runtime, and the code that needs it has access to the context anyway. --- Background: Coverage instrumentation generates two kinds of metadata that are embedded in the final binary. There is per-CGU information that goes in the `__llvm_covmap` linker section, and per-function information that goes in the `__llvm_covfun` section (except on Windows, where slightly different section names are used).
2024-10-26Use LLVM-C APIs for getting/setting linkageZalathar-13/+24
2024-10-26Add a wrapper type for raw enum values returned by LLVMZalathar-0/+25
2024-10-26Use safe wrappers `get_visibility` and `set_visibility`Zalathar-33/+20
2024-10-26Use safe wrappers `get_linkage` and `set_linkage`Zalathar-61/+60
2024-10-26coverage: Add links to LLVM docs for the coverage mapping formatZalathar-0/+2
2024-10-26Effects cleanupDeadbeef-3/+1
- removed extra bits from predicates queries that are no longer needed in the new system - removed the need for `non_erasable_generics` to take in tcx and DefId, removed unused arguments in callers
2024-10-25coverage: SSA doesn't need to know about `instrprof_increment`Zalathar-11/+12
2024-10-25coverage: Emit MC/DC intrinsics using the normal helper methodZalathar-49/+14
2024-10-25coverage: Emit `llvm.instrprof.increment` using the normal helper methodZalathar-25/+2
2024-10-25coverage: Store `covfun_section_name` in the codegen contextZalathar-27/+24
Adding an extra `OnceCell` to `CrateCoverageContext` is much nicer than trying to thread this string through multiple layers of function calls that already have access to the context.
2024-10-25coverage: Make obtaining the codegen coverage context infallibleZalathar-33/+16
In all the situations where this context is needed, it should always be available.
2024-10-25coverage: Consolidate creation of covmap/covfun recordsZalathar-88/+64
There is no need for this code to be split across multiple functions in multiple files.
2024-10-24Rollup merge of #131956 - Zalathar:llvm-counters, r=compiler-errors,SwatinemStuart Cook-353/+129
coverage: Pass coverage mappings to LLVM as separate structs Instead of trying to cram *N* different kinds of coverage mapping data into a single list for FFI, pass *N* different lists of simpler structs. This avoids the need to fill unused fields with dummy values, and avoids the need to tag structs with their underlying kind. It also lets us call the dedicated LLVM constructors for each different mapping type, instead of having to go through the complex general-purpose constructor. Even though this adds multiple new structs to the FFI surface area, the resulting C++ code is simpler and shorter. --- I've structured this mostly as a single atomic patch, rather than a series of incremental changes, because that avoids the need to make fiddly fixes to code that is about to be deleted anyway.
2024-10-23"innermost", "outermost", "leftmost", and "rightmost" don't need hyphensJosh Triplett-1/+1
These are all standard dictionary words and don't require hyphenation.
2024-10-21Auto merge of #130950 - compiler-errors:yeet-eval, r=BoxyUwUbors-10/+9
Continue to get rid of `ty::Const::{try_}eval*` This PR mostly does: * Removes all of the `try_eval_*` and `eval_*` helpers from `ty::Const`, and replace their usages with `try_to_*`. * Remove `ty::Const::eval`. * Rename `ty::Const::normalize` to `ty::Const::normalize_internal`. This function is still used in the normalization code itself. * Fix some weirdness around the `TransmuteFrom` goal. I'm happy to split it out further; for example, I could probably land the first part which removes the helpers, or the changes to codegen which are more obvious than the changes to tools. r? BoxyUwU Part of https://github.com/rust-lang/rust/issues/130704
2024-10-20Make `llvm::set_section` take a `&CStr`Zalathar-13/+14
2024-10-20Pass coverage mappings to LLVM as separate structsZalathar-336/+112
2024-10-20Reduce visibility of coverage FFI functions/typesZalathar-18/+18
2024-10-19Get rid of const eval_* and try_eval_* helpersMichael Goulet-10/+9
2024-10-19cg_llvm: Reuse LLVM-C Comdat supportJubilee Young-10/+25
Migrate `llvm::set_comdat` and `llvm::SetUniqueComdat` to LLVM-C FFI. Note, now we can call `llvm::set_comdat` only when the target actually supports adding comdat. As this has no convenient LLVM-C API, we implement this as `TargetOptions::supports_comdat`. Co-authored-by: Stuart Cook <Zalathar@users.noreply.github.com>
2024-10-18cg_llvm: Switch `llvm::add_global` to `&CStr`Jubilee Young-8/+9
2024-10-16rustc_target: Add pauth-lr aarch64 target featureKajetan Puchalski-0/+1
Add the pauth-lr target feature, corresponding to aarch64 FEAT_PAuth_LR. This feature has been added in LLVM 19. It is currently not supported by the Linux hwcap and so we cannot add runtime feature detection for it at this time.
2024-10-16llvm: Match aarch64 data layout to new LLVM layoutMatthew Maurer-0/+10
LLVM has added 3 new address spaces to support special Windows use cases. These shouldn't trouble us for now, but LLVM requires matching data layouts. See llvm/llvm-project#111879 for details
2024-10-14Fix AArch64InlineAsmReg::emitTaiki Endo-46/+5
2024-10-12Rollup merge of #131626 - matthiaskrgr:dont_string, r=lqdTrevor Gross-1/+1
remove a couple of redundant String to String conversion
2024-10-12remove a couple of redundant String to String conversionMatthias Krüger-1/+1
2024-10-12`LLVMConstInt` only allows integer typesDianQK-0/+13
2024-10-11Rollup merge of #124874 - jedbrown:float-mul-add-fast, r=saethlinTrevor Gross-0/+10
intrinsics fmuladdf{32,64}: expose llvm.fmuladd.* semantics Add intrinsics `fmuladd{f32,f64}`. This computes `(a * b) + c`, to be fused if the code generator determines that (i) the target instruction set has support for a fused operation, and (ii) that the fused operation is more efficient than the equivalent, separate pair of `mul` and `add` instructions. https://llvm.org/docs/LangRef.html#llvm-fmuladd-intrinsic The codegen_cranelift uses the `fma` function from libc, which is a correct implementation, but without the desired performance semantic. I think this requires an update to cranelift to expose a suitable instruction in its IR. I have not tested with codegen_gcc, but it should behave the same way (using `fma` from libc). --- This topic has been discussed a few times on Zulip and was suggested, for example, by `@workingjubilee` in [Effect of fma disabled](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Effect.20of.20fma.20disabled/near/274179331).
2024-10-11Rollup merge of #131543 - Zalathar:goodbye-llvm-17, r=petrochenkovTrevor Gross-15/+6
coverage: Remove code related to LLVM 17 In-tree LLVM is 19, and the minimum external LLVM was increased to 18 in #130487.
2024-10-11intrinsics.fmuladdf{16,32,64,128}: expose llvm.fmuladd.* semanticsJed Brown-0/+10
Add intrinsics `fmuladd{f16,f32,f64,f128}`. This computes `(a * b) + c`, to be fused if the code generator determines that (i) the target instruction set has support for a fused operation, and (ii) that the fused operation is more efficient than the equivalent, separate pair of `mul` and `add` instructions. https://llvm.org/docs/LangRef.html#llvm-fmuladd-intrinsic MIRI support is included for f32 and f64. The codegen_cranelift uses the `fma` function from libc, which is a correct implementation, but without the desired performance semantic. I think this requires an update to cranelift to expose a suitable instruction in its IR. I have not tested with codegen_gcc, but it should behave the same way (using `fma` from libc).
2024-10-11Rollup merge of #131519 - davidlattimore:intrinsics-default-vis, r=UrgauMatthias Krüger-4/+3
Use Default visibility for rustc-generated C symbol declarations Non-default visibilities should only be used for definitions, not declarations, otherwise linking can fail. This is based on https://github.com/rust-lang/rust/pull/123994. Issue https://github.com/rust-lang/rust/issues/123427 When I changed `default-hidden-visibility` to `default-visibility` in https://github.com/rust-lang/rust/pull/130005, I updated all places in the code that used `default-hidden-visibility`, replicating the hidden-visibility bug to also happen for protected visibility. Without this change, trying to build rustc with `-Z default-visibility=protected` fails with a link error.
2024-10-11coverage: Remove code related to LLVM 17Zalathar-15/+6
2024-10-11Use Default visibility for rustc-generated C symbol declarationsDavid Lattimore-4/+3
Non-default visibilities should only be used for definitions, not declarations, otherwise linking can fail. Co-authored-by: Collin Baker <collinbaker@chromium.org>
2024-10-10Rollup merge of #130741 - mrkajetanp:detect-b16b16, r=AmanieuMatthias Krüger-1/+3
rustc_target: Add sme-b16b16 as an explicit aarch64 target feature LLVM 20 split out what used to be called b16b16 and correspond to aarch64 FEAT_SVE_B16B16 into sve-b16b16 and sme-b16b16. Add sme-b16b16 as an explicit feature and update the codegen accordingly. Resolves https://github.com/rust-lang/rust/pull/129894.
2024-10-10Rollup merge of #130308 - davidtwco:tied-target-consolidation, r=wesleywiserMatthias Krüger-68/+5
codegen_ssa: consolidate tied target checks Fixes #105110. Fixes #105111. `rustc_codegen_llvm` and `rustc_codegen_gcc` duplicated logic for checking if tied target features were partially enabled. This PR consolidates these checks into `rustc_codegen_ssa` in the `codegen_fn_attrs` query, which also is run pre-monomorphisation for each function, which ensures that this check is run for unused functions, as would be expected. Also adds a test confirming that enabling one tied feature doesn't imply another - the appropriate error for this was already being emitted. I did a bisect and narrowed it down to two patches it was likely to be - something in #128796, probably #128221 or #128679.
2024-10-10rustc_target: Add sme-b16b16 as an explicit aarch64 target featureKajetan Puchalski-1/+3
LLVM 20 split out what used to be called b16b16 and correspond to aarch64 FEAT_SVE_B16B16 into sve-b16b16 and sme-b16b16. Add sme-b16b16 as an explicit feature and update the codegen accordingly.
2024-10-09Rollup merge of #131424 - workingjubilee:stem-the-tyde-of-glob-imports, ↵Matthias Krüger-7/+13
r=jieyouxu compiler: Stop reexporting enum-globs from `rustc_target::abi` Three enums had **all** their variants glob-exported into a distressingly large amount of the tree. Cease to do that, and also cease to glob import the contents of the module that contained them. Redirect relevant imports to their actual source, the `rustc_abi` crate. No functional changes.
2024-10-08compiler: Factor rustc_target::abi out of cg_llvmJubilee Young-7/+13
2024-10-08Dont ICE when encountering post-mono layout cycle errorMichael Goulet-5/+6
2024-10-08Auto merge of #126733 - ZhuUx:llvm-19-adapt, r=Zalatharbors-74/+43
[Coverage][MCDC] Adapt mcdc to llvm 19 Related issue: #126672 Also finish task 4 at #124144 [llvm #82448](https://github.com/llvm/llvm-project/pull/82448) has introduced some break changes into mcdc, causing incompatibility between llvm 18 and 19. This draft adapts to that change and gives up supporting for llvm-18.
2024-10-08coverage. Adapt to mcdc mapping formats introduced by llvm 19zhuyunxing-69/+24