about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm
AgeCommit message (Collapse)AuthorLines
2024-12-30rustc_llvm: expose FloatABIType target machine parameterRalf Jung-9/+18
2024-12-29make -Csoft-float have an effect on all ARM targetsRalf Jung-1/+1
2024-12-27Override `carrying_mul_add` in cg_llvmScott McMurray-0/+32
2024-12-23add LLVMRustDIBuilderCreateQualifiedType to ffiWalnut-0/+6
2024-12-20Remove some dead code around import library generationbjorn3-28/+0
This was missed when replacing the usage of LLVM for generating import libraries.
2024-12-19Rollup merge of #134497 - Zalathar:spans, r=jieyouxuMatthias Krüger-77/+200
coverage: Store coverage source regions as `Span` until codegen (take 2) This is an attempt to re-land #133418: > Historically, coverage spans were converted into line/column coordinates during the MIR instrumentation pass. > This PR moves that conversion step into codegen, so that coverage spans spend most of their time stored as Span instead. > In addition to being conceptually nicer, this also reduces the size of coverage mappings in MIR, because Span is smaller than 4x u32. That PR was reverted by #133608, because in some circumstances not covered by our test suite we were emitting coverage metadata that was causing `llvm-cov` to exit with an error (#133606). --- The implementation here is *mostly* the same, but adapted for subsequent changes in the relevant code (e.g. #134163). I believe that the changes in #134163 should be sufficient to prevent the problem that required the original PR to be reverted. But I haven't been able to reproduce the original breakage in a regression test, and the `llvm-cov` error message is extremely unhelpful, so I can't completely rule out the possibility of this breaking again. r? jieyouxu (reviewer of the original PR)
2024-12-19coverage: Add a synthetic test for when all spans are discardedZalathar-0/+11
2024-12-19coverage: Identify source files by ID, not by interned filenameZalathar-37/+33
2024-12-19coverage: Store coverage source regions as `Span` until codegenZalathar-26/+146
2024-12-19coverage: Quietly skip functions that end up having no mappingsZalathar-7/+2
In codegen, a used function with `FunctionCoverageInfo` but no mappings has historically indicated a bug. However, that will no longer be the case after moving some fallible span-processing steps into codegen.
2024-12-19coverage: Rename some FFI fields from `span` to `cov_span`Zalathar-9/+10
This will avoid confusion with actual `Span` spans.
2024-12-18fix outdated commentRalf Jung-2/+1
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
2024-12-18make no-variant types a dedicated Variants variantRalf Jung-20/+18
2024-12-18Variants::Single: do not use invalid VariantIdx for uninhabited enumsRalf Jung-6/+6
2024-12-18Auto merge of #134243 - nnethercote:re-export-more-rustc_span, r=jieyouxubors-10/+7
Re-export more `rustc_span::symbol` things from `rustc_span`. `rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers to `rustc_span::`. This is a 300+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one. r? `@jieyouxu`
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-10/+7
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-12-17Rollup merge of #134323 - Zalathar:dismantle-map-data, r=jieyouxuMatthias Krüger-204/+129
coverage: Dismantle `map_data.rs` by moving its responsibilities elsewhere This is a series of incremental changes that combine to let us get rid of `coverageinfo/map_data.rs`, by moving all of its responsibilities into more appropriate places. Some of the notable consequences are: - We once again build the per-CGU file table on the fly while preparing individual covfun records, instead of building the whole table up-front. The up-front approach was introduced by #117042 to work around various other problems in generating the covmap/covfun records, but subsequent cleanups have made that approach no longer necessary. - Expression conversion and mapping-region conversion are now performed directly in `mapgen::covfun`, which should make future changes easier. - We no longer insert unused function instances into the same map that is also used to track used function instances. This helps to decouple the handling of used vs unused functions. --- There should be no meaningful change to compiler output. The file table is no longer sorted, because reordering it would invalidate the file indices stored in individual covfun records, but the table order should still be deterministic (albeit arbitrary). There are some subsequent cleanups that I intend to investigate, but this is enough change for one PR.
2024-12-17coverage: Track used functions in a set instead of a mapZalathar-90/+37
This patch dismantles what was left of `FunctionCoverage` in `map_data.rs`, replaces `function_coverage_map` with a set, and overhauls how we prepare covfun records for unused functions.
2024-12-17coverage: Pull function source hash out of `map_data.rs`Zalathar-12/+7
2024-12-17coverage: Pull region conversion out of `map_data.rs`Zalathar-37/+14
2024-12-17coverage: Pull expression conversion out of `map_data.rs`Zalathar-33/+44
2024-12-17coverage: Build the global file table on the flyZalathar-33/+29
2024-12-17coverage: Use `is_eligible_for_coverage` to filter unused functionsZalathar-8/+7
The checks in `is_eligible_for_coverage` include `is_fn_like`, but will also exclude various function-like things that cannot possibly have coverage instrumentation.
2024-12-16rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structuresJonathan Dönszelmann-3/+3
2024-12-15Auto merge of #133417 - RalfJung:aarch64-float-abi, r=workingjubileebors-3/+3
reject aarch64 target feature toggling that would change the float ABI ~~Stacked on top of https://github.com/rust-lang/rust/pull/133099. Only the last two commits are new.~~ The first new commit lays the groundwork for separately controlling whether a feature may be enabled or disabled. The second commit uses that to make it illegal to *disable* the `neon` feature (which is only possible via `-Ctarget-feature`, and so the new check just adds a warning). Enabling the `neon` feature remains allowed on targets that don't disable `neon` or `fp-armv8`, which is all our built-in targets. This way, the entire PR is not a breaking change. Fixes https://github.com/rust-lang/rust/issues/131058 for hardfloat targets (together with https://github.com/rust-lang/rust/pull/133102 which fixed it for softfloat targets). Part of https://github.com/rust-lang/rust/issues/116344.
2024-12-14target_features: control separately whether enabling and disabling a target ↵Ralf Jung-3/+3
feature is allowed
2024-12-14Rollup merge of #134208 - Zalathar:covmap-covfun, r=compiler-errorsMatthias Krüger-65/+61
coverage: Tidy up creation of covmap and covfun records This is a small follow-up to #134163 that mostly just inlines and renames some variables, and adds a few comments. It also slightly defers the creation of the LLVM value that holds the filename table, to just before the value is needed. --- try-job: x86_64-mingw-2 try-job: dist-x86_64-linux
2024-12-13Auto merge of #133099 - RalfJung:forbidden-hardfloat-features, r=workingjubileebors-16/+20
forbid toggling x87 and fpregs on hard-float targets Part of https://github.com/rust-lang/rust/issues/116344, follow-up to https://github.com/rust-lang/rust/pull/129884: The `x87` target feature on x86 and the `fpregs` target feature on ARM must not be disabled on a hardfloat target, as that would change the float ABI. However, *enabling* `fpregs` on ARM is [explicitly requested](https://github.com/rust-lang/rust/issues/130988) as it seems to be useful. Therefore, we need to refine the distinction of "forbidden" target features and "allowed" target features: all (un)stable target features can determine on a per-target basis whether they should be allowed to be toggled or not. `fpregs` then checks whether the current target has the `soft-float` feature, and if yes, `fpregs` is permitted -- otherwise, it is not. (Same for `x87` on x86). Also fixes https://github.com/rust-lang/rust/issues/132351. Since `fpregs` and `x87` can be enabled on some builds and disabled on others, it would make sense that one can query it via `cfg`. Therefore, I made them behave in `cfg` like any other unstable target feature. The first commit prepares the infrastructure, but does not change behavior. The second commit then wires up `fpregs` and `x87` with that new infrastructure. r? `@workingjubilee`
2024-12-12coverage: Tidy up creation of covfun recordsZalathar-32/+34
2024-12-12coverage: Tidy up creation of covmap recordsZalathar-33/+27
2024-12-12Fix our `llvm::Bool` typedef to be signed, to match `LLVMBool`Zalathar-1/+3
In the LLVM-C API, boolean values are passed as `typedef int LLVMBool`, but our Rust-side typedef was using `c_uint` instead. Signed and unsigned integers have the same ABI on most platforms, but that isn't universally true, so we should prefer to be consistent with LLVM.
2024-12-12Auto merge of #129181 - beetrees:asm-spans, r=pnkfelix,compiler-errorsbors-19/+29
Pass end position of span through inline ASM cookie Before this PR, only the start position of the span was passed though the inline ASM cookie to diagnostics. LLVM 19 has full support for 64-bit inline ASM cookies; this PR uses that to pass the end position of the span in the upper 32 bits, meaning inline ASM diagnostics now point at the entire line the error occurred on, not just the first character of it.
2024-12-11Auto merge of #128004 - folkertdev:naked-fn-asm, r=Amanieubors-11/+11
codegen `#[naked]` functions using global asm tracking issue: https://github.com/rust-lang/rust/issues/90957 Fixes #124375 This implements the approach suggested in the tracking issue: use the existing global assembly infrastructure to emit the body of `#[naked]` functions. The main advantage is that we now have full control over what gets generated, and are no longer dependent on LLVM not sneakily messing with our output (inlining, adding extra instructions, etc). I discussed this approach with `@Amanieu` and while I think the general direction is correct, there is probably a bunch of stuff that needs to change or move around here. I'll leave some inline comments on things that I'm not sure about. Combined with https://github.com/rust-lang/rust/pull/127853, if both accepted, I think that resolves all steps from the tracking issue. r? `@Amanieu`
2024-12-11apply review feedbackRalf Jung-3/+5
2024-12-11generalize 'forbidden feature' concept so that even (un)stable feature can ↵Ralf Jung-16/+18
be invalid to toggle Also rename some things for extra clarity
2024-12-11Rollup merge of #134165 - durin42:wasm-target-string, r=jieyouxuMatthias Krüger-0/+5
wasm(32|64): update alignment string See llvm/llvm-project@c5ab70c508457eaece5d7ff4ab79a2f90bc67f06 `@rustbot` label: +llvm-main
2024-12-11Rollup merge of #134163 - Zalathar:covfun, r=SparrowLii,jieyouxuMatthias Krüger-182/+263
coverage: Rearrange the code for embedding per-function coverage metadata This is a series of refactorings to the code that prepares and embeds per-function coverage metadata records (“covfun records”) in the `__llvm_covfun` linker section of the final binary. The `llvm-cov` tool reads this metadata from the binary when preparing a coverage report. Beyond general cleanup, a big motivation behind these changes is to pave the way for re-landing an updated version of #133418. --- There should be no change in compiler output, as demonstrated by the absence of (meaningful) changes to coverage tests. The first patch is just moving code around, so I suggest looking at the other patches to see the actual changes. --- try-job: x86_64-gnu try-job: x86_64-msvc try-job: aarch64-apple
2024-12-11wasm(32|64): update alignment stringAugie Fackler-0/+5
See llvm/llvm-project@c5ab70c508457eaece5d7ff4ab79a2f90bc67f06 @rustbot label: +llvm-main
2024-12-11coverage: Store intermediate region tables in `CovfunRecord`Zalathar-55/+77
This defers the call to `llvm_cov::write_function_mappings_to_buffer` until just before its enclosing global variable is created.
2024-12-11coverage: Only generate a CGU's covmap record if it has covfun recordsZalathar-4/+14
2024-12-11coverage: Reify `CovfunRecord` as an intermediate stepZalathar-36/+45
2024-12-11coverage: Extract function metadata handling to a `covfun` submoduleZalathar-166/+206
2024-12-10codegen `#[naked]` functions using `global_asm!`Folkert-11/+11
2024-12-10Rollup merge of #134115 - durin42:ppc64-target-string, r=jieyouxuLeón Orell Valerian Liehr-0/+5
rustc_target: ppc64 target string fixes for LLVM 20 LLVM continues to clean these up, and we continue to make this consistent. This is similar to 9caced7badc337ced7ad89eb614621c39bd996e9, e9853961452b56997cc127b51308879b9cd09482, and a10e744fafa7eb3afef9a938097509bf4b225f84. ```@rustbot``` label: +llvm-main
2024-12-10Rollup merge of #134042 - sayantn:power8-crypto, r=jieyouxuLeón Orell Valerian Liehr-0/+3
Add the `power8-crypto` target feature Add the `power8-crypto` target feature. This will enable adding some new PPC intrinsics in stdarch (specifically AES, SHA and CLMUL intrinsics). The implied target feature is from [here](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/PowerPC/PPC.td) ```@rustbot``` label A-target-feature O-PowerPC
2024-12-10rustc_target: ppc64 target string fixes for LLVM 20Augie Fackler-0/+5
LLVM continues to clean these up, and we continue to make this consistent. This is similar to 9caced7badc337ced7ad89eb614621c39bd996e9, e9853961452b56997cc127b51308879b9cd09482, and a10e744fafa7eb3afef9a938097509bf4b225f84. `@rustbot` label: +llvm-main
2024-12-10Rollup merge of #134029 - Zalathar:zero, r=oli-obkLeón Orell Valerian Liehr-188/+26
coverage: Use a query to find counters/expressions that must be zero As of #133446, this query (`coverage_ids_info`) determines which counter/expression IDs are unused. So with only a little extra work, we can take the code that was using that information to determine which coverage counters/expressions must be zero, and move that inside the query as well. There should be no change in compiler output.
2024-12-09Auto merge of #134052 - matthiaskrgr:rollup-puxwqrk, r=matthiaskrgrbors-8/+3
Rollup of 7 pull requests Successful merges: - #133567 (A bunch of cleanups) - #133789 (Add doc alias 'then_with' for `then` method on `bool`) - #133880 (Expand home_dir docs) - #134036 (crash tests: use individual mir opts instead of mir-opt-level where easily possible) - #134045 (Fix some triagebot mentions paths) - #134046 (Remove ignored tests for hangs w/ new solver) - #134050 (Miri subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-09Rollup merge of #133567 - bjorn3:various_cleanups, r=cjgillotMatthias Krüger-8/+3
A bunch of cleanups These are all extracted from a branch I have to get rid of driver queries. Most of the commits are not directly necessary for this, but were found in the process of implementing the removal of driver queries. Previous PR: https://github.com/rust-lang/rust/pull/132410
2024-12-09Add the `power8-crypto` target featureSayantan Chakraborty-0/+3